結果

問題 No.1715 Dinner 2
ユーザー inksamuraiinksamurai
提出日時 2021-10-22 21:43:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,004 bytes
コンパイル時間 4,340 ms
コンパイル使用メモリ 169,988 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 12:45:03
合計ジャッジ時間 2,973 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 35 ms
4,348 KB
testcase_13 AC 26 ms
4,348 KB
testcase_14 AC 29 ms
4,348 KB
testcase_15 AC 34 ms
4,348 KB
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 -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 47 ms
4,348 KB
testcase_34 WA -
testcase_35 AC 52 ms
4,348 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3aILRlt ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
using pii=pair<int,int>;
using tpii=pair<pii,int>;
using vi=vector<int>;

int main(){
_3aILRlt;
	int n,d;
	cin>>n>>d;
	vec(pii) a(n);
	rep(i,n){
		cin>>a[i].fi>>a[i].se;
	}
	auto f=[&](int x)->bool{
		int now=0;
		vi usd(n,0);
		rep(_d,d){
			int maxima=-3e5,id=-1;
			rep(i,n){
				if(usd[i]) continue;
				if(now-a[i].fi>=x){
					if(-a[i].fi+a[i].se>maxima){
						maxima=-a[i].fi+a[i].se;
						id=i;
					}
				}
			}
			if(id==-1){
				return false;
			}
			usd[id]=1;
			now+=maxima;
		}
		return true;
	};
	int l=-1e8-1,r=1e8+1,c=-1;
	while(l<=r){
		int m=(l+r)/2;
		if(f(m)){
			c=m;
			l=m+1;
		}else{
			r=m-1;
		}
	}	
	cout<<c<<"\n";
//	
	return 0;
}
0