結果

問題 No.771 しおり
ユーザー kkey000kkey000
提出日時 2023-07-15 10:35:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 1,266 bytes
コンパイル時間 994 ms
コンパイル使用メモリ 97,636 KB
実行使用メモリ 40,412 KB
最終ジャッジ日時 2023-10-15 01:20:19
合計ジャッジ時間 5,558 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
40,164 KB
testcase_01 AC 20 ms
7,376 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,372 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 1 ms
4,372 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 AC 1 ms
4,368 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,368 KB
testcase_16 AC 2 ms
4,372 KB
testcase_17 AC 1 ms
4,368 KB
testcase_18 AC 1 ms
4,372 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 AC 1 ms
4,372 KB
testcase_21 AC 2 ms
4,368 KB
testcase_22 AC 2 ms
4,368 KB
testcase_23 AC 1 ms
4,372 KB
testcase_24 AC 1 ms
4,368 KB
testcase_25 AC 83 ms
20,880 KB
testcase_26 AC 3 ms
4,372 KB
testcase_27 AC 19 ms
7,248 KB
testcase_28 AC 41 ms
11,576 KB
testcase_29 AC 19 ms
7,244 KB
testcase_30 AC 182 ms
40,240 KB
testcase_31 AC 182 ms
40,212 KB
testcase_32 AC 6 ms
4,376 KB
testcase_33 AC 182 ms
40,232 KB
testcase_34 AC 182 ms
40,244 KB
testcase_35 AC 6 ms
4,372 KB
testcase_36 AC 2 ms
4,368 KB
testcase_37 AC 3 ms
4,372 KB
testcase_38 AC 6 ms
4,372 KB
testcase_39 AC 2 ms
4,368 KB
testcase_40 AC 84 ms
20,724 KB
testcase_41 AC 182 ms
40,412 KB
testcase_42 AC 182 ms
40,264 KB
testcase_43 AC 19 ms
7,180 KB
testcase_44 AC 181 ms
40,224 KB
testcase_45 AC 182 ms
40,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>


#define INF 1e9
using namespace std;

int main()
{

    int n;
    cin >> n;
    vector<pair<long long int, long long int>> x; 
    for (int i = 0; i < n; i++)
    {
        int j, k;
        cin >> j >> k;
        x.push_back(make_pair(j, k - j));

    }
    
    long long int b[1 << n][n];
    for (int i = 0; i < (1 << n); i++)
    {
        for(int j = 0; j < n; j++){
            b[i][j] = INF;

        }
    }
    for (int i = 0; i < n; i++)
    {
        b[(1 << i)][i] = 0;

    }

    for (int i = 1; i < (1 << n); i++)
    {
        for (int j = 0; j < n; j++)
        {

            for (int k = 0; k < n; k++)
            {
                if ((i >> k) % 2 == 1)
                    continue;
                int nexti = i | (1 << k);
 
                b[nexti][k] = min(b[nexti][k], max(b[i][j], x[j].second + x[k].first));
   
            }
        }
    }
    int ans = INF;
    for (int i = 0; i < n; i++)
    {
        if (b[(1 << n) - 1][i] < ans)
        {
            ans = b[(1 << n) - 1][i];
        }
    }
    cout << ans << endl;
    return 0; 
}
0