結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー 👑 kmjpkmjp
提出日時 2017-09-08 23:17:02
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,935 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 162,160 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2024-04-24 21:18:50
合計ジャッジ時間 6,822 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In instantiation of ‘V BIT<V, ME>::add(int, V) [with V = int; int ME = 20]’:
main.cpp:43:23:   required from here
main.cpp:19:77: warning: no return statement in function returning non-void [-Wreturn-type]
   19 |         V add(int e,V v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
      |                                                                             ^

ソースコード

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;}
	V 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];

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);
			if(X[i]==2) bt2.add(B[i],1);
		}
	}
	
	int mi=101010;
	for(i=100001;i>=0;i--) {
		FORR(e,V[i]) {
			if(X[e]==0) {
				bt1.add(B[e],1);
			}
			if(X[e]==1) {
				bt1.add(B[e],-1);
				bt2.add(B[e],1);
			}
			if(X[e]==2) {
				bt2.add(B[e],-1);
				R3++;
			}
		}
		
		int R2=bt2.total(101010);
		int left=bt1.total(101100);
		int need=M-min(M,R2+R3);
		if(need>left) continue;
		
		int diff=(1<<18)-1;
		for(j=17;j>=0;j--) if(left-bt1.total(diff-(1<<j)-1)<need) diff-=1<<j;
		mi=min(mi,R3+(R2-bt2.total(diff-1)));
		
	}
	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