結果

問題 No.771 しおり
ユーザー hiro71687khiro71687k
提出日時 2023-03-24 15:01:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 1,107 bytes
コンパイル時間 4,881 ms
コンパイル使用メモリ 265,260 KB
実行使用メモリ 50,408 KB
最終ジャッジ日時 2023-10-18 20:28:43
合計ジャッジ時間 9,073 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 212 ms
50,408 KB
testcase_01 AC 22 ms
8,040 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 2 ms
4,348 KB
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 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 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 98 ms
24,936 KB
testcase_26 AC 4 ms
4,348 KB
testcase_27 AC 22 ms
8,040 KB
testcase_28 AC 48 ms
14,112 KB
testcase_29 AC 22 ms
8,040 KB
testcase_30 AC 214 ms
50,408 KB
testcase_31 AC 213 ms
50,408 KB
testcase_32 AC 6 ms
4,532 KB
testcase_33 AC 214 ms
50,408 KB
testcase_34 AC 214 ms
50,408 KB
testcase_35 AC 6 ms
4,532 KB
testcase_36 AC 3 ms
4,348 KB
testcase_37 AC 3 ms
4,348 KB
testcase_38 AC 6 ms
4,532 KB
testcase_39 AC 3 ms
4,348 KB
testcase_40 AC 99 ms
24,936 KB
testcase_41 AC 213 ms
50,408 KB
testcase_42 AC 214 ms
50,408 KB
testcase_43 AC 21 ms
8,040 KB
testcase_44 AC 214 ms
50,408 KB
testcase_45 AC 214 ms
50,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=1444999999994;
ll mod=1000000007;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n),b(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    vector<ll>two(30,1);
    for (ll i = 0; i < 29; i++)
    {
        two[i+1]=two[i]*2;
    }
    vector<vector<ll>>dp(two[n],vector<ll>(n,inf));
    for (ll i = 0; i < n; i++)
    {
        dp[two[i]][i]=0;
    }
    for (ll i = 1; i < two[n]; i++)
    {
        for (ll j = 0; j < n; j++)
        {
            if (!(i&two[j]))
            {
                continue;
            }
            for (ll k = 0; k < n; k++)
            {
                if (i&two[k])
                {
                    continue;
                }
                dp[i+two[k]][k]=min(dp[i+two[k]][k],max(dp[i][j],b[j]-a[j]+a[k]));
            }
        }
    }
    ll ans=inf;
    for (ll i = 0; i < n; i++)
    {
        ans=min(ans,dp[two[n]-1][i]);
    }
    cout << ans << endl;
}
0