2020-06-29 to 2020-07-02

2020-06-29

  • 買了枕頭。(希望早點到)
  • 兩頓都在食堂喫。
  • 我給迷惑行爲打賞投稿的沙雕被採納了。
  • 晚上有出去夜跑。

Codeforces Round #653 (Div. 3)

E2 - Reading Books (hard version)

和我昨天E1的思路類似。(題意在昨天)

還是要分成四類,主要枚舉兩者都喜歡的書選用的個數p3

那麼那些被單獨喜歡的書至少要選k-p3本。

剩下如果還不足m本書,我們就在沒人喜歡,和單獨喜歡的書中貪心挑。

稍微用一點編程技巧優化,複雜度不會很大。

我被.size()卡住了。注意一般size_t類型都是被編譯器解釋成無符號類型的。如果參與邏輯運算,會把所有的數值都轉化成無符號類型運算。這樣就讓負數會產生意外。

/**
  *    █████╗  ██████╗       ██████╗ ██╗     ███████╗
  *   ██╔══██╗██╔════╝       ██╔══██╗██║     ╚══███╔╝
  *   ███████║██║            ██████╔╝██║       ███╔╝
  *   ██╔══██║██║            ██╔═══╝ ██║      ███╔╝
  *   ██║  ██║╚██████╗▄█╗    ██║     ███████╗███████╗
  *   ╚═╝  ╚═╝ ╚═════╝╚═╝    ╚═╝     ╚══════╝╚══════╝
  *
  *  @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沒意思了,明天整理一下藍橋。

2020-06-30

  • 整理一下藍橋杯的東西。
  • 牛客劍指offer
  • 字節跳動?(問問學姐(哇太難了,有點做夢。
  • 數據學院?(沒通知(來了來了。
  • snowkylin.github.io 雪老師也太優秀了,我頂禮膜拜。
  • 明天要去打掃衛生。迴歸機房生活啦。
  • 就寫了兩題,晚上還跑步了,明天再說。

2020-07-01

  • 大清早去機房打掃衛生,發現很多人都要離開了。
  • 買了力扣的30天會員,玩玩看。
  • 刷了好多困難題,其實還不算太難。
  • 打了div2,但是感覺好像不是很會= =。(想學一下E和F)
  • 晚上跑步了,還修好了機房的網絡,挺好的。
  • 明天九點多去機房貼二維碼。
  • 明天八點強717優惠券。
  • 一天就這麼過去了,明天再接再厲。

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:

Aus der Kriegsschule des Lebens. — Was mich nicht umbringt, macht mich stärker.
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

專業見習動員大會

我總結一下開會的內容:

  • 專業實習課程推掉的還是要選上,學號姓名報給我,我幫大家申請回來。
  • 延期的同學分數會遲點補錄,不影響。
  • 延期申請表有空就寫起來交給教務辦(應該是找周瑩老師),最遲開學第一週交過去。
  • 實習時間要求在9月多開始,我們要至少10周(注意填寫材料)。
  • 平臺在校友幫,大多數材料都在校友幫上可以下載。
  • 實在找不到實習,早點去教務辦跟老師交流一下。
  • 他們要求實習崗位要和專業相關,因爲你的材料會給專業主任審覈的,他覺得不行可能會申請不通過。

2020-07-02

  • 早上去機房貼了二維碼(有四個位置我貼反了)
  • leetcode做了兩道題。
  • 去取了快遞,有新枕頭了,開心。(辰巨聽信了一套梳子護髮的理論,我也開始相信了。)
  • 今天好多陣雨暴雨,出去很不爽。
  • 晚上在看藍橋杯2019B
  • 中間水羣有點太多啦,以後少水一點。
  • 沒什麼特別的想記錄。(拖了藍橋杯的整理)
  • 中/後綴表達式

走馬觀花

無意中看到一個py庫,Fabric,裏面也有裝飾器¶的概念。這讓我感覺到學設計模式還是很有必要性的,畢竟可以感知到這個東西大概是什麼樣的。

計劃書寫法

考研計劃書
項目概述
項目內容
立項依據
項目意義
項目內容及目標
項目可行性分析
項目初始方案
項目規劃
項目預算
參考

link

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章