結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー WA_TLEWA_TLE
提出日時 2017-08-17 17:05:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,393 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 132,292 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 15:41:17
合計ジャッジ時間 4,839 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
/*
JOI委員会(JanJan Otosu Iinkai)は、何らかの合宿の選考をしているようだ。
この大会では、解き終えたときの時間や、WA数を一切考慮しないので、単純に完答数が重要になる。
いま、本選に出す問題のうち3問は確定したが、AとBの2問だけ決まってない。
2問の難易度はそれぞれ独立に,0以上100001以下の整数に決めれる。

JOI本選にn人の参加者がいる。(n<=200000)
合宿の予算がないので、委員会は残った2問の難易度をうまく調整して
2完以上を達成した人数をm人以上にしつつ、3完以上を最小化したい。(m<=n)
各人の能力から、(Xi,Ai,Bi)が与えられる。(0<=Xi<=3,1<=Ai,Bi<=100000)
Xiは、すでに決まった問題のうち完答できる数である。
Aiは、全体的なA問題の難易度をSAとしたとき、Ai>=SAなら完答できる、という意味である。
Biは、全体的なB問題の難易度をSBとしたとき、Bi>=SBなら完答できる、という意味である。

その時の、3完以上の人数を出力せよ。

※この問題はフィクションです。実在する組織、人物名には一切関係ありません。
*/
const int maxsei=100001;
int main(void){
	int i,n,m;cin>>n>>m;
	vector<int> kan(n);
	vector<pair<int,int>> a(n);
	vector<pair<int,int>> b(n);
	int ni=0,san=0;//2完以上、3完以上
	int SA=0,SB=maxsei;//a難易度、b難易度
	int ans=1e9;
	int aAC=n,bAC=0;//AC数
	int deAnan=-1,deBnan=-1;
	for(i=0;i<n;i++){
		int xi,ai,bi;cin>>xi>>ai>>bi;
		kan[i]=xi+1;
		a[i]=mp(ai,i);
		b[i]=mp(bi,i);
		if(xi>=1){ni++;}
		if(xi>=2){san++;}//aは簡単なので
	}
	sort(a.rbegin(),a.rend());//解けそうな順にソート
	sort(b.rbegin(),b.rend());//解けそうな順にソート
	while(-1){
		//cout<<"de SA="<<SA<<" SB="<<SB<<" ni="<<ni<<" san="<<san<<endl;
		if(ni<m){
			SB--;
			if(SB<0){break;}
			while(bAC<n&&b[bAC].fir>=SB){
				if(kan[b[bAC].sec]==1){ni++;}
				if(kan[b[bAC].sec]==2){san++;}
				kan[b[bAC].sec]++;
				bAC++;
			}
		}else{
			if(mineq(ans,san)){
				deAnan=SA;
				deBnan=SB;
			}
			
			SA++;
			if(SA>maxsei){break;}
			while(aAC>0&&a[aAC-1].fir<SA){
				if(kan[a[aAC-1].sec]==2){ni--;}
				if(kan[a[aAC-1].sec]==3){san--;}
				kan[a[aAC-1].sec]--;
				aAC--;
			}
		}
	}
	cout<<ans<<" A="<<deAnan<<" B="<<deBnan<<endl;
	return 0;
}
0