結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー gigimegigime
提出日時 2017-09-08 23:37:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 1,000 ms
コード長 1,077 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 169,100 KB
実行使用メモリ 12,204 KB
最終ジャッジ日時 2023-08-20 09:13:19
合計ジャッジ時間 3,757 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
12,192 KB
testcase_01 AC 65 ms
12,116 KB
testcase_02 AC 5 ms
8,264 KB
testcase_03 AC 5 ms
8,304 KB
testcase_04 AC 6 ms
8,324 KB
testcase_05 AC 5 ms
8,240 KB
testcase_06 AC 5 ms
8,180 KB
testcase_07 AC 5 ms
8,284 KB
testcase_08 AC 5 ms
8,264 KB
testcase_09 AC 5 ms
8,240 KB
testcase_10 AC 5 ms
8,248 KB
testcase_11 AC 5 ms
8,236 KB
testcase_12 AC 57 ms
12,204 KB
testcase_13 AC 57 ms
12,012 KB
testcase_14 AC 56 ms
11,848 KB
testcase_15 AC 57 ms
11,956 KB
testcase_16 AC 57 ms
11,912 KB
testcase_17 AC 57 ms
11,816 KB
testcase_18 AC 55 ms
11,828 KB
testcase_19 AC 58 ms
11,984 KB
testcase_20 AC 54 ms
11,888 KB
testcase_21 AC 59 ms
12,048 KB
testcase_22 AC 59 ms
12,184 KB
testcase_23 AC 5 ms
8,180 KB
testcase_24 AC 5 ms
8,184 KB
testcase_25 AC 5 ms
8,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,M;
const int MAX_N = 100000;
vector<int> X;
int cnt [10];
vector<int> A [MAX_N + 1],B [MAX_N + 1];

int main()
{
	scanf("%d%d",&N,&M);
	X.assign(N,0);
	FOR(i,0,N){
		int a,b;
		scanf("%d%d%d",&X [i],&a,&b);
		A [a].push_back(i);
		B [b].push_back(i);
		X [i]++;
		cnt [X [i]]++;
	}

	int ans = MAX_N,p = MAX_N;
	for(int i = -1;i <= MAX_N;i++){
		if(i >= 0){
			FOR(j,0,A [i].size()){
				cnt [X [A [i] [j]]]--;
				X [A [i] [j]]--;
				cnt [X [A [i] [j]]]++;
			}
		}
		while(p >= 0 && accumulate(cnt + 2,cnt + 6,0) < M){
			FOR(j,0,B [p].size()){
				cnt [X [B [p] [j]]]--;
				X [B [p] [j]]++;
				cnt [X [B [p] [j]]]++;
			}
			p--;
		}
		if(accumulate(cnt + 2,cnt + 6,0) >= M){
			chmin(ans,accumulate(cnt + 3,cnt + 6,0));
		}
	}
	printf("%d\n",ans);

	return 0;
}
0