結果

問題 No.771 しおり
ユーザー NacoNaco
提出日時 2019-10-11 15:45:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 764 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 166,480 KB
実行使用メモリ 22,040 KB
最終ジャッジ日時 2023-09-29 12:59:50
合計ジャッジ時間 5,692 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 220 ms
22,000 KB
testcase_01 AC 24 ms
7,336 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 102 ms
13,600 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 24 ms
7,424 KB
testcase_28 AC 49 ms
9,456 KB
testcase_29 AC 24 ms
7,340 KB
testcase_30 AC 219 ms
21,776 KB
testcase_31 AC 219 ms
21,876 KB
testcase_32 AC 6 ms
4,376 KB
testcase_33 AC 220 ms
21,752 KB
testcase_34 AC 220 ms
22,040 KB
testcase_35 AC 6 ms
4,376 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 6 ms
4,376 KB
testcase_39 AC 3 ms
4,376 KB
testcase_40 AC 103 ms
13,620 KB
testcase_41 AC 220 ms
21,700 KB
testcase_42 AC 219 ms
21,680 KB
testcase_43 AC 24 ms
7,484 KB
testcase_44 AC 219 ms
21,828 KB
testcase_45 AC 219 ms
21,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int dp[(1<<18)][18];

const int INF=1e9;

int main(){
    int N; cin >> N;
    int a[N],b[N];
    for(int i=0;i<N;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0;i<(1<<N);i++){
        for(int j=0;j<N;j++){
            dp[i][j]=INF;
        }
    }
    for(int i=0;i<N;i++) dp[1<<i][i]=0;
    for(int mask=0;mask<(1<<N);mask++){
        for(int i=0;i<N;i++){
            if(!mask&(1<<i)) continue;
            for(int j=0;j<N;j++){
                if(mask&(1<<j)) continue;
                dp[mask|(1<<j)][j]=min(dp[mask|(1<<j)][j],max(dp[mask][i],b[i]-a[i]+a[j]));
            }
        }
    }
    int ans=INF;
    for(int i=0;i<N;i++){
        ans=min(ans,dp[(1<<N)-1][i]);
    }
    cout << ans << endl;
}
0