結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー Hoget157Hoget157
提出日時 2017-09-08 23:23:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,149 bytes
コンパイル時間 1,880 ms
コンパイル使用メモリ 176,896 KB
実行使用メモリ 12,320 KB
最終ジャッジ日時 2024-04-24 21:32:47
合計ジャッジ時間 4,830 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
12,316 KB
testcase_01 AC 133 ms
12,320 KB
testcase_02 AC 5 ms
6,656 KB
testcase_03 AC 5 ms
6,912 KB
testcase_04 AC 5 ms
6,656 KB
testcase_05 WA -
testcase_06 AC 5 ms
6,784 KB
testcase_07 AC 5 ms
6,656 KB
testcase_08 AC 5 ms
6,656 KB
testcase_09 AC 5 ms
6,528 KB
testcase_10 AC 6 ms
6,784 KB
testcase_11 AC 6 ms
6,656 KB
testcase_12 WA -
testcase_13 AC 126 ms
12,164 KB
testcase_14 AC 126 ms
12,252 KB
testcase_15 AC 132 ms
12,140 KB
testcase_16 AC 119 ms
11,960 KB
testcase_17 AC 115 ms
11,964 KB
testcase_18 AC 120 ms
12,204 KB
testcase_19 AC 123 ms
12,136 KB
testcase_20 AC 113 ms
12,112 KB
testcase_21 AC 121 ms
11,948 KB
testcase_22 WA -
testcase_23 AC 5 ms
6,912 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),two(n);
	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