結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー kyunakyuna
提出日時 2019-06-20 23:14:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 1,000 ms
コード長 967 bytes
コンパイル時間 1,047 ms
コンパイル使用メモリ 74,044 KB
実行使用メモリ 12,996 KB
最終ジャッジ日時 2023-08-24 15:51:56
合計ジャッジ時間 4,346 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
12,972 KB
testcase_01 AC 103 ms
12,992 KB
testcase_02 AC 5 ms
8,100 KB
testcase_03 AC 5 ms
8,084 KB
testcase_04 AC 4 ms
8,112 KB
testcase_05 AC 5 ms
8,088 KB
testcase_06 AC 5 ms
8,100 KB
testcase_07 AC 5 ms
8,168 KB
testcase_08 AC 5 ms
8,092 KB
testcase_09 AC 5 ms
8,052 KB
testcase_10 AC 4 ms
8,084 KB
testcase_11 AC 5 ms
8,092 KB
testcase_12 AC 95 ms
12,948 KB
testcase_13 AC 96 ms
12,580 KB
testcase_14 AC 93 ms
12,712 KB
testcase_15 AC 96 ms
12,724 KB
testcase_16 AC 90 ms
12,424 KB
testcase_17 AC 96 ms
12,460 KB
testcase_18 AC 94 ms
12,520 KB
testcase_19 AC 96 ms
12,680 KB
testcase_20 AC 94 ms
12,472 KB
testcase_21 AC 95 ms
12,536 KB
testcase_22 AC 104 ms
12,996 KB
testcase_23 AC 5 ms
8,144 KB
testcase_24 AC 3 ms
8,068 KB
testcase_25 AC 5 ms
8,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

int main() {
    int n, m; cin >> n >> m;
    vector<int> x(n), a(n), b(n), cnt(6), va[101010], vb[101010];
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> a[i] >> b[i];
        va[a[i]].emplace_back(i);
        vb[b[i]].emplace_back(i);
        ++cnt[++x[i]];
    }
    int ans = INF;
    int sb = 100001;
    for (int sa = 0; sa <= 100001; ++sa) {
        // 2 完以上が m 人未満
        while (cnt[2] + cnt[3] + cnt[4] + cnt[5] < m && --sb >= 0) {
            for (int i: vb[sb]) {
                --cnt[x[i]];
                ++cnt[++x[i]];
            }
        }
        if (cnt[2] + cnt[3] + cnt[4] + cnt[5] >= m) {
            ans = min(ans, cnt[3] + cnt[4] + cnt[5]);
            for (int i: va[sa]) {
                --cnt[x[i]];
                ++cnt[--x[i]];
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0