結果

問題 No.1715 Dinner 2
ユーザー cureskolcureskol
提出日時 2021-10-22 21:30:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 794 bytes
コンパイル時間 2,447 ms
コンパイル使用メモリ 177,784 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 12:23:13
合計ジャッジ時間 3,651 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 70 ms
4,348 KB
testcase_12 AC 60 ms
4,348 KB
testcase_13 AC 46 ms
4,348 KB
testcase_14 AC 54 ms
4,348 KB
testcase_15 AC 59 ms
4,348 KB
testcase_16 AC 57 ms
4,348 KB
testcase_17 AC 37 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 8 ms
4,348 KB
testcase_26 AC 5 ms
4,348 KB
testcase_27 AC 6 ms
4,348 KB
testcase_28 AC 6 ms
4,348 KB
testcase_29 AC 7 ms
4,348 KB
testcase_30 AC 7 ms
4,348 KB
testcase_31 AC 8 ms
4,348 KB
testcase_32 AC 86 ms
4,348 KB
testcase_33 AC 86 ms
4,348 KB
testcase_34 AC 96 ms
4,348 KB
testcase_35 AC 97 ms
4,348 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n-1);i>=0;i--)
#define ALL(v) v.begin(),v.end()

const int INF=1e9+7;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,d;cin>>n>>d;
  vector<int> p(n),q(n);
  REP(i,n)cin>>p[i]>>q[i];
  int ok=-INF,ng=INF;
  while(ng-ok>1){
    int mid=(ok+ng)>>1;
    int pre=-1,now=0;
    bool out=false;
    REP(_,d){
      int idx=-1;
      REP(i,n){
        if(i==pre)continue;
        if(now-p[i]<mid)continue;
        if(idx==-1||q[i]-p[i]>q[idx]-p[idx])idx=i;
      }
      if(idx==-1){
        out=true;
        break;
      }
      now+=q[idx]-p[idx];
      pre=idx;
    }
    if(out)ng=mid;
    else ok=mid;
  }
  cout<<ok<<endl;
}
0