結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー kotatsugamekotatsugame
提出日時 2020-03-05 15:28:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,328 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 02:34:07
合計ジャッジ時間 3,378 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
6,812 KB
testcase_01 AC 88 ms
6,940 KB
testcase_02 AC 9 ms
6,944 KB
testcase_03 AC 8 ms
6,944 KB
testcase_04 AC 8 ms
6,944 KB
testcase_05 AC 5 ms
6,940 KB
testcase_06 AC 8 ms
6,944 KB
testcase_07 AC 8 ms
6,940 KB
testcase_08 WA -
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 8 ms
6,940 KB
testcase_12 AC 87 ms
6,940 KB
testcase_13 AC 92 ms
6,940 KB
testcase_14 AC 89 ms
6,944 KB
testcase_15 WA -
testcase_16 AC 86 ms
6,940 KB
testcase_17 AC 85 ms
6,944 KB
testcase_18 AC 87 ms
6,944 KB
testcase_19 AC 92 ms
6,944 KB
testcase_20 AC 85 ms
6,940 KB
testcase_21 AC 89 ms
6,944 KB
testcase_22 AC 88 ms
6,944 KB
testcase_23 AC 8 ms
6,940 KB
testcase_24 AC 4 ms
6,944 KB
testcase_25 AC 4 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//1-indexed
#include<vector>
template<typename T>
struct BIT{
	int n;
	vector<T>bit;
	BIT(int n_=0):n(n_),bit(n_+1){}
	T sum(int i)
	{
		T ans=0;
		for(;i>0;i-=i&-i)ans+=bit[i];
		return ans;
	}
	void add(int i,T a)
	{
		if(i==0)return;
		for(;i<=n;i+=i&-i)bit[i]+=a;
	}
	int lower_bound(T k)//k<=sum(ret)
	{
		if(k<=0)return 0;
		int ret=0,i=1;
		while((i<<1)<=n)i<<=1;
		for(;i;i>>=1)
			if(ret+i<=n&&bit[ret+i]<k)k-=bit[ret+=i];
		return ret+1;
	}
};
int N,M;
vector<pair<int,int> >X[4];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)
	{
		int x,a,b;cin>>x>>a>>b;
		X[x].push_back(make_pair(100001-a,100001-b));
	}
	int ans=N;
	BIT<int>P(1<<17),Q(1<<17);
	for(int i=0;i<3;i++)sort(X[i].begin(),X[i].end());
	for(pair<int,int>p:X[1])P.add(p.second,1);
	for(pair<int,int>p:X[2])Q.add(p.second,1);
	int i[3]={};
	int cnt3=X[3].size();
	for(int SA=0;SA<=100001;SA++)
	{
		for(int j=0;j<3;j++)
		{
			while(i[j]<X[j].size()&&X[j][i[j]].first<=SA)
			{
				int B=X[j][i[j]].second;
				if(j==0)P.add(B,1);
				else if(j==1)
				{
					P.add(B,-1);
					Q.add(B,1);
				}
				else
				{
					Q.add(B,-1);
					cnt3++;
				}
				i[j]++;
			}
		}
		int left=M-cnt3-Q.sum(1<<17);
		int k=P.lower_bound(left);
		ans=min(ans,cnt3+Q.sum(k));
	}
	cout<<ans<<endl;
}
0