結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー TsubaMukkuTsubaMukku
提出日時 2020-02-15 15:04:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 1,000 ms
コード長 1,919 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 166,912 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-04-16 03:11:52
合計ジャッジ時間 3,716 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
13,380 KB
testcase_01 AC 60 ms
13,440 KB
testcase_02 AC 5 ms
8,320 KB
testcase_03 AC 5 ms
8,132 KB
testcase_04 AC 5 ms
8,448 KB
testcase_05 AC 5 ms
8,448 KB
testcase_06 AC 5 ms
8,320 KB
testcase_07 AC 5 ms
8,192 KB
testcase_08 AC 6 ms
8,260 KB
testcase_09 AC 5 ms
8,320 KB
testcase_10 AC 5 ms
8,132 KB
testcase_11 AC 5 ms
8,192 KB
testcase_12 AC 60 ms
13,184 KB
testcase_13 AC 63 ms
13,184 KB
testcase_14 AC 62 ms
13,128 KB
testcase_15 AC 64 ms
13,056 KB
testcase_16 AC 59 ms
13,056 KB
testcase_17 AC 61 ms
12,872 KB
testcase_18 AC 62 ms
12,996 KB
testcase_19 AC 63 ms
13,056 KB
testcase_20 AC 61 ms
12,928 KB
testcase_21 AC 64 ms
13,056 KB
testcase_22 AC 65 ms
13,312 KB
testcase_23 AC 5 ms
8,320 KB
testcase_24 AC 5 ms
8,320 KB
testcase_25 AC 4 ms
8,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/


#define INF INT_MAX/2
int N, M;
int X[101010], A[101010], B[101010];
int cnt[10];
//---------------------------------------------------------------------------------------------------
vector<int> a[101010], b[101010];
void _main() {
    cin >> N >> M;
    rep(i, 0, N) cin >> X[i] >> A[i] >> B[i];
    rep(i, 0, N) {
        a[A[i]].push_back(i);
        b[B[i]].push_back(i);
    }

    rep(i, 0, N) X[i]++;
    rep(i, 0, N) cnt[X[i]]++;

    int ans = INF;
    int SB = 100001;
    rep(SA, 0, 100002) {
        while (cnt[2] + cnt[3] + cnt[4] + cnt[5] < M) {
            SB--;
            if (SB < 0) break;
            fore(i, b[SB]) {
                cnt[X[i]]--;
                X[i]++;
                cnt[X[i]]++;
            }
        }
        if (cnt[2] + cnt[3] + cnt[4] + cnt[5] < M) break;

        ans = min(ans, cnt[3] + cnt[4] + cnt[5]);

        fore(i, a[SA]) {
            cnt[X[i]]--;
            X[i]--;
            cnt[X[i]]++;
        }
    }
    cout << ans << endl;
}
0