結果
| 問題 |
No.771 しおり
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-15 06:22:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 248 ms / 2,000 ms |
| コード長 | 730 bytes |
| コンパイル時間 | 2,290 ms |
| コンパイル使用メモリ | 171,624 KB |
| 実行使用メモリ | 29,824 KB |
| 最終ジャッジ日時 | 2024-12-27 13:07:43 |
| 合計ジャッジ時間 | 6,217 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n), b(n);
vector<vector<int>> dp(1 << n, vector<int>(n, 1 << 30));
for(int i = 0; i < n; i++){
cin >> a[i] >> b[i];
dp[1 << i][i] = 0;
}
for(int i = 0; i < (1 << n); i++){
for(int j = 0; j < n; j++){
if(~i >> j & 1)continue;
for(int k = 0; k < n; k++){
if(i >> k & 1)continue;
dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], max(dp[i][j], b[j] - a[j] + a[k]));
}
}
}
cout << *min_element(dp.back().begin(), dp.back().end()) << '\n';
}