結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-09-09 21:49:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 1,000 ms
コード長 1,919 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 168,264 KB
実行使用メモリ 13,260 KB
最終ジャッジ日時 2023-08-20 09:48:25
合計ジャッジ時間 3,759 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
13,188 KB
testcase_01 AC 62 ms
13,260 KB
testcase_02 AC 5 ms
8,088 KB
testcase_03 AC 5 ms
8,148 KB
testcase_04 AC 5 ms
8,232 KB
testcase_05 AC 5 ms
8,164 KB
testcase_06 AC 6 ms
8,180 KB
testcase_07 AC 5 ms
8,092 KB
testcase_08 AC 5 ms
8,148 KB
testcase_09 AC 5 ms
8,156 KB
testcase_10 AC 5 ms
8,156 KB
testcase_11 AC 5 ms
8,160 KB
testcase_12 AC 56 ms
12,928 KB
testcase_13 AC 59 ms
13,032 KB
testcase_14 AC 56 ms
13,036 KB
testcase_15 AC 57 ms
13,004 KB
testcase_16 AC 53 ms
12,924 KB
testcase_17 AC 57 ms
12,824 KB
testcase_18 AC 57 ms
12,864 KB
testcase_19 AC 61 ms
12,988 KB
testcase_20 AC 58 ms
12,860 KB
testcase_21 AC 59 ms
12,856 KB
testcase_22 AC 64 ms
13,200 KB
testcase_23 AC 5 ms
8,096 KB
testcase_24 AC 5 ms
8,372 KB
testcase_25 AC 5 ms
8,156 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