結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー Hoget157Hoget157
提出日時 2017-09-08 23:30:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,157 bytes
コンパイル時間 1,964 ms
コンパイル使用メモリ 178,596 KB
実行使用メモリ 12,652 KB
最終ジャッジ日時 2023-08-07 03:27:13
合計ジャッジ時間 5,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
12,240 KB
testcase_01 AC 121 ms
12,120 KB
testcase_02 AC 4 ms
6,820 KB
testcase_03 AC 5 ms
6,512 KB
testcase_04 AC 4 ms
6,572 KB
testcase_05 WA -
testcase_06 AC 4 ms
6,580 KB
testcase_07 AC 5 ms
6,580 KB
testcase_08 AC 4 ms
6,576 KB
testcase_09 AC 4 ms
6,584 KB
testcase_10 AC 5 ms
6,528 KB
testcase_11 AC 4 ms
6,724 KB
testcase_12 WA -
testcase_13 AC 123 ms
12,096 KB
testcase_14 AC 120 ms
11,844 KB
testcase_15 AC 133 ms
11,772 KB
testcase_16 AC 110 ms
11,936 KB
testcase_17 AC 105 ms
12,108 KB
testcase_18 AC 111 ms
11,852 KB
testcase_19 AC 112 ms
11,972 KB
testcase_20 AC 106 ms
11,744 KB
testcase_21 AC 114 ms
11,716 KB
testcase_22 WA -
testcase_23 AC 5 ms
6,704 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

class BIT{
	vector<int> bit;
public:
	BIT(int siz){
		bit.resize(siz + 1,0);
	}
	void add(int i,int x){
		i++;
		while(i < bit.size()){
			bit[i] += x;
			i += i & -i;
		}
	}
	int sum(int i){
		i++;
		int s = 0;
		while(i){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
};

typedef pair<int,int> PP;
typedef pair<int,PP> P;

signed main(){
	int n,m,kan2 = 0,kan3 = 0,mi = INF,last[100002];
	cin >> n >> m;
	BIT one(n + 5),two(n + 5);
	vector<P> vec;
	vector<int> upd[100002];
	for(int i = 0;i < 100002;i++) last[i] = -1;
	for(int i = 0;i < n;i++){
		int x,a,b;
		cin >> x >> a >> b;
		vec.push_back(mp(b,mp(x,a)));
		if(x >= 2) kan2++;
		if(x >= 3) kan3++;
	}
	sort(vec.begin(),vec.end(),greater<P>());
	for(int i = 0;i < n;i++){
		upd[vec[i].second.second].push_back(i);
		if(vec[i].second.first == 1) one.add(i,1);
		else if(vec[i].second.first == 2) two.add(i,1);
		last[vec[i].first] = i;
	}
	for(int i = 100000;i >= 0;i--) if(last[i] == -1) last[i] = last[i + 1];
	for(int i = 100001;i >= 0;i--){
		if(!upd[i].size()) continue;
		for(int v : upd[i]){
			if(vec[v].second.first == 0){
				one.add(v,1);
			}
			else if(vec[v].second.first == 1){
				one.add(v,-1);
				two.add(v,1);
				kan2++;
			}
			else if(vec[v].second.first == 2){
				two.add(v,-1);
				kan3++;
			}
			vec[v].second.first++;
		}
		int low = -1,up = 100002;
		while(up - low > 1){
			int mid = (low + up) / 2;
			if(kan2 + one.sum(last[mid]) >= m) low = mid;
			else up = mid;
		}
		if(kan2 + one.sum(last[low]) < m) continue;
		mi = min(mi,kan3 + two.sum(last[low]));
	}
	cout << mi << endl;
	return 0;
}
0