結果

問題 No.771 しおり
コンテスト
ユーザー Shuz*
提出日時 2018-12-02 23:55:02
言語 C++14
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 505 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 896 ms
コンパイル使用メモリ 181,248 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2026-08-03 01:59:34
合計ジャッジ時間 7,834 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 42
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, _##i = (n); i < _##i; ++i)
#define INF 100000
#define MAX_N 20
int N, counter, res = INF, A[MAX_N], B[MAX_N], P[MAX_N];

signed main() {
    cin >> N;
    rep(i, N) cin >> A[i] >> B[i], B[i] -= A[i];
    rep(i, N) P[i] = i;
    do {
        counter = 0;
        rep(i, N - 1) counter = max(counter, B[P[i]] + A[P[i + 1]]);
        res = min(res, counter);
    } while (next_permutation(P, P + N));
    cout << res << endl;
}
0