結果
問題 | No.771 しおり |
ユーザー | Shuz* |
提出日時 | 2018-12-01 20:28:58 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 183 ms / 2,000 ms |
コード長 | 3,714 bytes |
コンパイル時間 | 1,515 ms |
コンパイル使用メモリ | 171,384 KB |
実行使用メモリ | 45,520 KB |
最終ジャッジ日時 | 2024-07-22 07:03:34 |
合計ジャッジ時間 | 4,907 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 183 ms
44,872 KB |
testcase_01 | AC | 20 ms
9,076 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | AC | 2 ms
6,944 KB |
testcase_25 | AC | 82 ms
24,748 KB |
testcase_26 | AC | 4 ms
6,940 KB |
testcase_27 | AC | 20 ms
9,744 KB |
testcase_28 | AC | 38 ms
15,028 KB |
testcase_29 | AC | 20 ms
9,512 KB |
testcase_30 | AC | 177 ms
44,576 KB |
testcase_31 | AC | 179 ms
44,664 KB |
testcase_32 | AC | 6 ms
6,944 KB |
testcase_33 | AC | 183 ms
45,520 KB |
testcase_34 | AC | 182 ms
45,400 KB |
testcase_35 | AC | 6 ms
6,944 KB |
testcase_36 | AC | 3 ms
6,940 KB |
testcase_37 | AC | 3 ms
6,944 KB |
testcase_38 | AC | 6 ms
6,944 KB |
testcase_39 | AC | 3 ms
6,940 KB |
testcase_40 | AC | 85 ms
24,532 KB |
testcase_41 | AC | 182 ms
45,392 KB |
testcase_42 | AC | 181 ms
45,388 KB |
testcase_43 | AC | 20 ms
8,804 KB |
testcase_44 | AC | 183 ms
45,168 KB |
testcase_45 | AC | 181 ms
45,040 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; //#include <boost/multiprecision/cpp_int.hpp> // using namespace boost::multiprecision; // using cint = cpp_int; //#pragma GCC optimize("", on) //#pragma GCC optimization_level 3 //#define min(...) min({...}) //#define max(...) max({...}) // Define using ll = long long; using ull = unsigned long long; using ld = long double; const ll MOD = 1e9 + 7; const ll INF = LONG_MAX; const ull MAX = ULONG_MAX; #define mp make_pair #define pb push_back #define eb emplace_back #define x first #define y second #define endl '\n' #define space ' ' #define def inline auto #define func inline constexpr ll #define run __attribute__((constructor)) def _ #define all(v) begin(v), end(v) #define input(a) scanf("%lld", &(a)) #define print(a) printf("%lld\n", (a)) // Debug #define debug(...) \ { \ cerr << __LINE__ << ": " << #__VA_ARGS__ << " = "; \ for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] "; \ cerr << endl; \ } #define dump(a, h, w) \ { \ cerr << __LINE__ << ": " << #a << " = [" << endl; \ rep(i, h) { \ rep(j, w) cerr << a[i][j] << space; \ cerr << endl; \ } \ cerr << "]" << endl; \ } #define vdump(a, n) \ { \ cerr << __LINE__ << ": " << #a << " = ["; \ rep(i, n) if (i) cerr << space << a[i]; \ else cerr << a[i]; \ cerr << "]" << endl; \ } // Loop #define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i) #define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i) #define each(i, a) for (auto &&i : a) #define rep(i, n) inc(i, 0, (n) -1) #define loop() for (;;) // Stream #define fout(n) cout << fixed << setprecision(n) #define fasten cin.tie(0), ios::sync_with_stdio(0) // Speed run() { fasten, fout(10); } #pragma GCC optimize("O3") #pragma GCC target("avx") // Math func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } func lcm(ll a, ll b) { return a * b / gcd(a, b); } func sign(ll a) { return a ? abs(a) / a : 0; } def in() { ll A; cin >> A; return A; } #define MAX_N 20 ll N, A[MAX_N], B[MAX_N], DP[1 << MAX_N][MAX_N]; signed main() { cin >> N; rep(i, N) cin >> A[i] >> B[i], B[i] -= A[i]; rep(i, 1 << N) rep(j, N) DP[i][j] = INF; rep(bit, (1 << N)) { rep(v, N) { if (!((bit >> v) & 1)) continue; rep(u, N) { if ((bit >> u) & 1) continue; DP[bit | (1 << u)][u] = min(DP[bit | (1 << u)][u], max(DP[bit][v] == INF ? 0 : DP[bit][v], B[v] + A[u])); } } } cout << *min_element(DP[(1 << N) - 1], DP[(1 << N) - 1] + N) << endl; } // for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17