2020-06-29 to 2020-07-02

2020-06-29

  • Bought a pillow. (Hope to arrive early)
  • Both meals were eaten in the cafeteria.
  • The sand sculpture I contributed to the bewildering behavior was accepted.
  • Go out for a night run at night.

Codeforces Round #653 (Div. 3)

E2 - Reading Books (hard version)

Similar to my idea of ​​E1 yesterday. (The title is intended to be yesterday)

Still have to be divided into four categories, mainly enumerating the number of books that both like p3.

Then the books that are liked individually must be selected at least k-p3.

If there are still less than m books, we will be greedy to choose among books that no one likes and we like alone.

Use a little programming skill to optimize, the complexity will not be great.

I am .size()stuck. Note that the general size_t type is interpreted as an unsigned type by the compiler. If involved in logical operations, all values ​​will be converted into unsigned type operations. This makes negative numbers cause accidents.

/**
  *    █████╗  ██████╗       ██████╗ ██╗     ███████╗
  *   ██╔══██╗██╔════╝       ██╔══██╗██║     ╚══███╔╝
  *   ███████║██║            ██████╔╝██║       ███╔╝
  *   ██╔══██║██║            ██╔═══╝ ██║      ███╔╝
  *   ██║  ██║╚██████╗▄█╗    ██║     ███████╗███████╗
  *   ╚═╝  ╚═╝ ╚═════╝╚═╝    ╚═╝     ╚══════╝╚══════╝
  *
  *  @Author: TieWay59
  *  @Created: 2020/6/29 15:46
  *  @Link: https://codeforces.com/contest/1374/problem/E2
  *  @Tags:
  *
  *******************************************************/

#include <bits/stdc++.h>

#ifdef DEBUG

#   include "libs59/debugers.h"
//  #define debug(x)  cerr <<#x << " = "<<x<<endl;
#else
#   define endl '\n'
#   define debug(...)
#   define max(x,y) ((x)>(y)?(x):(y))
#   define min(x,y) ((x)>(y)?(y):(x))
#endif

#define STOPSYNC ios::sync_with_stdio(false);cin.tie(nullptr)
#define MULTIKASE int Kase=0;cin>>Kase;for(int kase=1;kase<=Kase;kase++)
#define SIZE(x)  int((x).size())
typedef long long ll;
const int MAXN = 2e5 + 59;
const int MOD = 1e9 + 7;
const int INF = 0x3F3F3F3F;
const ll llINF = 0x3F3F3F3F3F3F3F3F;
using namespace std;
using pii = pair<ll, ll>;
using vint = vector<int>;


void solve(int kaseId = -1) {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<pii>> a(4);

    for (int i = 1; i <= n; ++i) {
        ll ti, ai, bi;
        cin >> ti >> ai >> bi;
        a[ai << 1 | bi].emplace_back(ti, i);
    }

    for (auto &ai : a) {
        sort(ai.begin(), ai.end());
    }

    auto sum(a);

    for (auto &ai : sum) {
        int pre = 0;
        for (auto &aij : ai) {
            aij.first += pre;
            pre = aij.first;
        }
    }


    int p0 = 0;
    int p1 = 0;
    int p2 = 0;
    ll ans_val = llINF;
    vint ans_ps;

    auto get_time = [&a](const int &tp, const int &ps) -> ll {
        if (ps >= SIZE(a[tp])) return llINF;
        return a[tp][ps].first;
    };

    for (int p3 = min(m, (int) a[3].size()); p3 >= 0; --p3) {
        if (k - p3 > min(SIZE(a[1]), SIZE(a[2]))) continue;
        if (m - p3 > SIZE(a[0]) + SIZE(a[1]) + SIZE(a[2])) continue;
        if (m - p3 < (k - p3) * 2) continue;

        ll t = p3 > 0 ? sum[3][p3 - 1].first : 0ll;

        p2 = max(p2, k - p3);
        p1 = max(p1, k - p3);
        p0 = min(p0, m - p3 - p2 - p1);

        while (p3 + p2 + p1 + p0 < m) {
            ll x2 = get_time(2, p2);
            ll x1 = get_time(1, p1);
            ll x0 = get_time(0, p0);
            if (x0 <= min(x1, x2)) p0++;
            else if (x1 <= min(x0, x2)) p1++;
            else p2++;
        }

        if (p2) t += sum[2][p2 - 1].first;
        if (p1) t += sum[1][p1 - 1].first;
        if (p0) t += sum[0][p0 - 1].first;

        if (t < ans_val) {
            ans_val = t;
            ans_ps = {p0, p1, p2, p3};
            debug(ans_ps);
        }
    }

    if (ans_val == llINF) {
        cout << -1 << endl;
    } else {
        cout << ans_val << endl;
        for (int i = 0; i < 4; ++i) {
            for (int j = 0; j < ans_ps[i]; ++j) {
                cout << a[i][j].second << " ";
            }
        }
        cout << endl;
    }
}

void solves() {
    MULTIKASE {
        solve(kase);
    }
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r+", stdin);
#endif
    STOPSYNC;

    solve();
    return 0;
}
/*

 */

F is boring. I will sort out the blue bridge tomorrow.

2020-06-30

  • Organize the things in the Lanqiao Cup.
  • Niu Ke Jian Zhi offer
  • Byte beating? (Ask Senior Sister (Wow, it's too hard, a little dreaming.)
  • Data Academy? (No notice (coming here.)
  • Snowkylin.github.io teacher Xue is also too good, I worship.
  • I'm going to clean up tomorrow. Back to life in the computer room.
  • I wrote two questions and jogged at night, so I will talk about it tomorrow.

2020-07-01

  • I went to clean the computer room early in the morning and found that many people were leaving.
  • I bought a 30-day member of Likou, and have fun.
  • I have brushed a lot of difficult questions, but it is not too difficult.
  • I hit div2, but it doesn't seem to be very good at ==. (I want to learn E and F)
  • I ran at night and fixed the network in the computer room, which was good.
  • Go to the computer room to paste the QR code at nine o'clock tomorrow.
  • Strong 717 coupons tomorrow at 8 o'clock.
  • One day has passed, and we will continue our efforts tomorrow.

What does not kill me makes me stronger

From Wikipedia, the free encyclopedia

Jump to navigationJump to search

What does not kill me makes me stronger (German Was mich nicht umbringt macht mich stärker) is part of aphorism number 8 from the “Maxims and Arrows” section of Friedrich Nietzsche’s Twilight of the Idols (1888). In full, it is:

From the war school of life. - What does not kill me, makes me stronger.
Out of life's school of war - What does not kill me makes me stronger.

It is quoted or alluded to by many other works, with minor variants in wording

wiki

Professional Trainee Mobilization Conference

Let me summarize the content of the meeting:

  • If the professional internship courses are rejected, they still have to be selected. Report the student ID name to me, and I will help you apply back.
  • Students whose scores are postponed will be added later and will not be affected.
  • Write the extension application form when you have time and give it to the Academic Affairs Office (you should find Teacher Zhou Ying), and submit it by the first week of school at the latest.
  • The internship period is required to start in September, and we need at least 10 weeks (pay attention to fill in the materials).
  • The platform is in the alumni gang, and most of the materials can be downloaded on the alumni gang.
  • I really can't find an internship, so go to the Academic Affairs Office to communicate with the teacher.
  • They require the internship position to be related to the major, because your materials will be reviewed by the professional director, and he may not pass the application if he thinks it is not possible.

2020-07-02

  • I posted the QR code in the computer room in the morning (I posted it upside down in four places)
  • Leetcode did two questions.
  • I went to pick up the courier and got a new pillow, happy. (Chen Ju believed a set of comb hair care theory, and I began to believe it.)
  • There were a lot of rain and heavy rain today, and it was very uncomfortable to go out.
  • Watching the Blue Bridge Cup 2019B at night .
  • There is too much water in the middle, so there will be less water in the future.
  • There is nothing special to record. (Dragging the finishing of the Blue Bridge Cup)
  • Mid/postfix expression ?

Walk around

I accidentally saw a py library, Fabric, which also has the concept of decorator¶ . This makes me feel that it is necessary to learn design patterns, after all, I can perceive what this thing is like.

Plan notation

考研计划书
项目概述
项目内容
立项依据
项目意义
项目内容及目标
项目可行性分析
项目初始方案
项目规划
项目预算
参考

link

Guess you like

Origin blog.csdn.net/Tighway/article/details/107097041