結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-09-09 21:49:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,917 bytes
コンパイル時間 1,589 ms
コンパイル使用メモリ 166,788 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-04-25 00:47:25
合計ジャッジ時間 4,291 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
13,312 KB
testcase_01 AC 46 ms
13,312 KB
testcase_02 AC 5 ms
8,448 KB
testcase_03 AC 4 ms
8,448 KB
testcase_04 AC 5 ms
8,320 KB
testcase_05 AC 5 ms
8,448 KB
testcase_06 AC 5 ms
8,192 KB
testcase_07 AC 5 ms
8,320 KB
testcase_08 RE -
testcase_09 AC 6 ms
8,192 KB
testcase_10 AC 5 ms
8,448 KB
testcase_11 AC 5 ms
8,320 KB
testcase_12 AC 48 ms
13,056 KB
testcase_13 AC 50 ms
13,056 KB
testcase_14 AC 50 ms
13,056 KB
testcase_15 RE -
testcase_16 AC 46 ms
12,928 KB
testcase_17 AC 45 ms
13,056 KB
testcase_18 AC 48 ms
12,928 KB
testcase_19 AC 46 ms
13,184 KB
testcase_20 AC 47 ms
13,056 KB
testcase_21 AC 45 ms
13,056 KB
testcase_22 AC 47 ms
13,440 KB
testcase_23 AC 5 ms
8,320 KB
testcase_24 AC 4 ms
8,448 KB
testcase_25 AC 4 ms
8,192 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]]++;
            }
        }
        assert(M <= cnt[2] + cnt[3] + cnt[4] + cnt[5]);

        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