結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー boutarouboutarou
提出日時 2021-07-31 12:42:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 1,000 ms
コード長 1,599 bytes
コンパイル時間 1,921 ms
コンパイル使用メモリ 204,336 KB
実行使用メモリ 13,028 KB
最終ジャッジ日時 2023-10-14 14:52:38
合計ジャッジ時間 4,671 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
12,896 KB
testcase_01 AC 50 ms
12,896 KB
testcase_02 AC 5 ms
7,700 KB
testcase_03 AC 5 ms
7,844 KB
testcase_04 AC 4 ms
7,756 KB
testcase_05 AC 5 ms
7,700 KB
testcase_06 AC 4 ms
7,780 KB
testcase_07 AC 5 ms
7,784 KB
testcase_08 AC 4 ms
7,712 KB
testcase_09 AC 4 ms
7,800 KB
testcase_10 AC 4 ms
7,956 KB
testcase_11 AC 5 ms
7,812 KB
testcase_12 AC 44 ms
12,624 KB
testcase_13 AC 46 ms
12,628 KB
testcase_14 AC 44 ms
12,400 KB
testcase_15 AC 45 ms
12,384 KB
testcase_16 AC 42 ms
12,396 KB
testcase_17 AC 44 ms
12,652 KB
testcase_18 AC 44 ms
12,636 KB
testcase_19 AC 46 ms
12,620 KB
testcase_20 AC 43 ms
12,532 KB
testcase_21 AC 45 ms
12,524 KB
testcase_22 AC 45 ms
13,028 KB
testcase_23 AC 5 ms
7,704 KB
testcase_24 AC 4 ms
7,776 KB
testcase_25 AC 4 ms
7,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
using ll = long long;
using P = pair<int, int>;

// Aの難易度は0から上げていく、Bの難易度は100001から2完の人数を満たすまで尺取り式に下げていく

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n, m; cin >> n >> m;
    vector<int> x(n), a(n), b(n);
    rep(i, n) cin >> x[i] >> a[i] >> b[i];
    // a_li[x] = a[i] = xなるiのリスト
    vector<vector<int>> a_li(100002), b_li(100002);
    rep(i, n) {
        a_li[a[i]].push_back(i);
        b_li[b[i]].push_back(i);
    }

    int INF = 1e9;
    int ans = INF;
    int a_diff = 0, b_diff = 100001;
    int nikan = 0, sankan = 0;
    rep(i, n) {
        x[i]++; // この時点でAは全員正解できるため
        if (x[i] >= 2) nikan++;
        if (x[i] >= 3) sankan++;
    }
    for (; a_diff <= 100001; a_diff++) {
        // 二冠の人数が足りるまでb_diffを下げていく
        while (b_diff > 0 && nikan < m) {
            b_diff--;
            for (auto elem : b_li[b_diff]) {
                x[elem]++;
                if (x[elem] == 2) nikan++;
                if (x[elem] == 3) sankan++;
            }
        }
        if (nikan < m) break;
        ans = min(ans, sankan);

        // a_diffを上げる処理、a[i] = a_diffなるiについてx[i]--
        for (auto elem : a_li[a_diff]) {
            x[elem]--;
            if (x[elem] == 1) nikan--;
            if (x[elem] == 2) sankan--;
        }
    }
    cout << ans << endl;
    return 0;
}
0