結果
| 問題 |
No.1715 Dinner 2
|
| コンテスト | |
| ユーザー |
inksamurai
|
| 提出日時 | 2021-10-22 22:12:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 995 bytes |
| コンパイル時間 | 1,567 ms |
| コンパイル使用メモリ | 170,408 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-23 05:46:40 |
| 合計ジャッジ時間 | 2,933 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 35 WA * 3 |
ソースコード
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (ll)a.size()
#define rep(i,n) for(ll i=0;i<n;i++)
#define drep(i,n) for(ll 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<ll,ll>;
using tpii=pair<pii,ll>;
using vi=vector<ll>;
int main(){
_3aILRlt;
ll n,d;
cin>>n>>d;
vec(pii) a(n);
rep(i,n){
cin>>a[i].fi>>a[i].se;
}
auto f=[&](ll x)->bool{
ll now=0,oid=-1;
vi usd(n,0);
rep(_d,d){
ll maxima=-1e9,id=-1;
rep(i,n){
if(i==oid) 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;
}
now+=maxima;
oid=id;
}
return true;
};
ll l=-1e9-1,r=1e9+1,c=-1;
while(l<=r){
ll m=(l+r)/2;
if(f(m)){
c=m;
l=m+1;
}else{
r=m-1;
}
}
cout<<c<<"\n";
//
return 0;
}
inksamurai