結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー 👑 kmjpkmjp
提出日時 2017-09-08 23:19:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 109 ms / 1,000 ms
コード長 1,920 bytes
コンパイル時間 1,494 ms
コンパイル使用メモリ 163,440 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-04-18 21:38:52
合計ジャッジ時間 5,115 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
9,856 KB
testcase_01 AC 109 ms
9,856 KB
testcase_02 AC 28 ms
6,016 KB
testcase_03 AC 28 ms
5,888 KB
testcase_04 AC 28 ms
6,016 KB
testcase_05 AC 42 ms
5,888 KB
testcase_06 AC 27 ms
6,016 KB
testcase_07 AC 28 ms
5,888 KB
testcase_08 AC 5 ms
5,888 KB
testcase_09 AC 43 ms
5,888 KB
testcase_10 AC 43 ms
5,888 KB
testcase_11 AC 28 ms
6,016 KB
testcase_12 AC 99 ms
9,728 KB
testcase_13 AC 87 ms
9,728 KB
testcase_14 AC 85 ms
9,728 KB
testcase_15 AC 70 ms
9,728 KB
testcase_16 AC 89 ms
9,856 KB
testcase_17 AC 96 ms
9,600 KB
testcase_18 AC 81 ms
9,856 KB
testcase_19 AC 85 ms
9,600 KB
testcase_20 AC 87 ms
9,728 KB
testcase_21 AC 78 ms
9,728 KB
testcase_22 AC 95 ms
9,856 KB
testcase_23 AC 28 ms
5,888 KB
testcase_24 AC 43 ms
6,016 KB
testcase_25 AC 43 ms
5,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<class V, int ME> class BIT {
public:
	V bit[1<<ME],val[1<<ME];
	V total(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
	V set(int e,V v) { add(e,v-val[e]);}
	int lower_bound(V val) {
		V tv=0; int i,ent=0;
		for(i=ME-1;i>=0;i--) if(tv+bit[ent+(1<<i)-1]<val) tv+=bit[ent+(1<<i)-1],ent+=(1<<i);
		return ent;
	}
};
BIT<int,20> bt1,bt2;

int N,M;
int X[101010],A[101010],B[101010];
vector<int> V[101010];
int R1,R2,R3;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	int R3=0;
	FOR(i,N) {
		cin>>X[i]>>A[i]>>B[i];
		if(X[i]>=3) R3++, i--, N--;
		else {
			V[A[i]].push_back(i);
			if(X[i]==1) bt1.add(B[i],1),R1++;
			if(X[i]==2) bt2.add(B[i],1),R2++;
		}
	}
	
	int mi=101010;
	for(i=100001;i>=0;i--) {
		FORR(e,V[i]) {
			if(X[e]==0) {
				bt1.add(B[e],1),R1++;
			}
			if(X[e]==1) {
				bt1.add(B[e],-1),R1--;
				bt2.add(B[e],1),R2++;
			}
			if(X[e]==2) {
				bt2.add(B[e],-1),R2--;
				R3++;
			}
		}
		
		int need=M-min(M,R2+R3);
		if(need>R1) continue;
		
		int diff=(1<<18)-1;
		for(j=17;j>=0;j--) if(R1-bt1.total(diff-(1<<j)-1)<need) diff-=1<<j;
		mi=min(mi,R3+(R2-bt2.total(diff-2)));
		
	}
	cout<<mi<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0