結果
| 問題 |
No.771 しおり
|
| コンテスト | |
| ユーザー |
t33f
|
| 提出日時 | 2018-12-22 17:39:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 260 ms / 2,000 ms |
| コード長 | 657 bytes |
| コンパイル時間 | 595 ms |
| コンパイル使用メモリ | 66,388 KB |
| 実行使用メモリ | 21,888 KB |
| 最終ジャッジ日時 | 2024-07-22 07:07:57 |
| 合計ジャッジ時間 | 4,721 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
#include <iostream>
using namespace std;
int n, a[20], b[20];
inline int calc(int i, int j) {
return a[j] + b[i] - a[i];
}
int memo[1<<18][18];
int solve(int s, int i) {
if (memo[s][i] > 0) return memo[s][i];
int ans = 1<<30;
int s1 = s ^ (1<<i);
if (s1 == 0) ans = 0;
for (int j = 0; j < n; j++) {
if (s1 & (1<<j)) {
ans = min(ans, max(solve(s1, j), calc(j, i)));
}
}
return memo[s][i] = ans;
}
int main () {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
int ans = 1<<30;
for (int i = 0; i < n; i++) ans = min(ans, solve((1<<n)-1, i));
cout << ans << endl;
}
t33f