結果

問題 No.1715 Dinner 2
ユーザー tko919tko919
提出日時 2021-10-22 22:00:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 940 bytes
コンパイル時間 2,057 ms
コンパイル使用メモリ 208,444 KB
実行使用メモリ 11,256 KB
最終ジャッジ日時 2023-10-24 13:08:47
合計ジャッジ時間 19,173 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1,308 ms
9,408 KB
testcase_12 AC 1,185 ms
8,352 KB
testcase_13 AC 1,079 ms
7,560 KB
testcase_14 AC 1,108 ms
8,352 KB
testcase_15 AC 1,254 ms
8,352 KB
testcase_16 AC 908 ms
8,088 KB
testcase_17 AC 455 ms
6,240 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 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 17 ms
4,348 KB
testcase_26 AC 10 ms
4,348 KB
testcase_27 AC 12 ms
4,348 KB
testcase_28 AC 14 ms
4,348 KB
testcase_29 AC 14 ms
4,348 KB
testcase_30 AC 14 ms
4,348 KB
testcase_31 AC 15 ms
4,348 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 1 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}



int main(){
    int n,d;
    cin>>n>>d;
    vector<int> p(n),q(n);
    rep(i,0,n)cin>>p[i]>>q[i];

    using P=pair<int,int>;
    vector dp(d+1,vector<P>(n,{-inf,-inf}));
    rep(i,0,n){
        dp[1][i]={-p[i],q[i]-p[i]};
    }
    rep(j,1,d)rep(i,0,n){
        rep(to,0,n)if(i!=to){
            auto [x,y]=dp[j][i];
            chmin(x,y-p[to]);
            y+=q[to]-p[to];
            chmax(dp[j+1][to],P{x,y});
        }
    }
    int res=-inf;
    rep(i,0,n)chmax(res,dp[d][i].first);
    cout<<res<<'\n';
    return 0;
}
0