結果
問題 | No.2542 Yokan for Two |
ユーザー | Maxdorian |
提出日時 | 2023-11-25 10:17:21 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,483 ms / 2,000 ms |
コード長 | 1,091 bytes |
コンパイル時間 | 5,348 ms |
コンパイル使用メモリ | 316,512 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2023-11-25 10:17:55 |
合計ジャッジ時間 | 32,891 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,676 KB |
testcase_01 | AC | 3 ms
6,676 KB |
testcase_02 | AC | 2 ms
6,676 KB |
testcase_03 | AC | 247 ms
9,728 KB |
testcase_04 | AC | 479 ms
6,676 KB |
testcase_05 | AC | 793 ms
11,392 KB |
testcase_06 | AC | 3 ms
6,676 KB |
testcase_07 | AC | 1,483 ms
12,160 KB |
testcase_08 | AC | 317 ms
10,368 KB |
testcase_09 | AC | 1,465 ms
11,776 KB |
testcase_10 | AC | 220 ms
6,676 KB |
testcase_11 | AC | 346 ms
6,676 KB |
testcase_12 | AC | 640 ms
10,880 KB |
testcase_13 | AC | 213 ms
6,676 KB |
testcase_14 | AC | 748 ms
7,552 KB |
testcase_15 | AC | 893 ms
7,936 KB |
testcase_16 | AC | 865 ms
7,680 KB |
testcase_17 | AC | 763 ms
7,296 KB |
testcase_18 | AC | 887 ms
8,064 KB |
testcase_19 | AC | 576 ms
6,676 KB |
testcase_20 | AC | 504 ms
6,676 KB |
testcase_21 | AC | 541 ms
6,676 KB |
testcase_22 | AC | 533 ms
6,676 KB |
testcase_23 | AC | 573 ms
6,676 KB |
testcase_24 | AC | 7 ms
6,676 KB |
testcase_25 | AC | 13 ms
6,676 KB |
testcase_26 | AC | 13 ms
6,676 KB |
testcase_27 | AC | 15 ms
6,676 KB |
testcase_28 | AC | 18 ms
6,676 KB |
testcase_29 | AC | 250 ms
11,776 KB |
testcase_30 | AC | 810 ms
7,168 KB |
testcase_31 | AC | 828 ms
7,040 KB |
testcase_32 | AC | 796 ms
7,040 KB |
testcase_33 | AC | 850 ms
7,296 KB |
testcase_34 | AC | 938 ms
7,936 KB |
testcase_35 | AC | 955 ms
7,936 KB |
testcase_36 | AC | 943 ms
7,808 KB |
testcase_37 | AC | 983 ms
8,192 KB |
testcase_38 | AC | 947 ms
8,320 KB |
testcase_39 | AC | 960 ms
8,576 KB |
testcase_40 | AC | 902 ms
8,320 KB |
testcase_41 | AC | 899 ms
7,936 KB |
testcase_42 | AC | 883 ms
7,936 KB |
testcase_43 | AC | 888 ms
8,064 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using ull = unsigned long long; template <class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;} template <class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;} const int INF = INT_MAX / 2; const ll LINF = 1LL << 60; const vector<int> dx = {-1, 0, 1, 0}, dy = {0, 1, 0, -1}; using mint = modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(0); int l, n; cin >> l >> n; vector<int> x(n); for (int i = 0; i < n; i++) { cin >> x[i]; } map<int, int> mp; mp[x[0]] = 1; for (int i = 1; i < n; i++) { map<int, int> mp2; for (int j = -(int)1e5; j <= (int)1e5; j++) { if (mp.count(j)) { mp2[j + x[i] - x[i - 1]] = 1; mp2[j - (x[i] - x[i - 1])] = 1; } } swap(mp, mp2); } int ans = INF; for (int i = -(int)1e5; i <= (int)1e5; i++) { if (mp.count(i)) { chmin(ans, abs(i - (l - x[n - 1]))); } } cout << ans << '\n'; return 0; }