結果
問題 |
No.2542 Yokan for Two
|
ユーザー |
|
提出日時 | 2025-07-04 22:29:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 571 bytes |
コンパイル時間 | 1,843 ms |
コンパイル使用メモリ | 200,796 KB |
実行使用メモリ | 389,924 KB |
最終ジャッジ日時 | 2025-07-04 22:29:54 |
合計ジャッジ時間 | 8,271 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 38 TLE * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main () { int L, N; cin >> L >> N; set<int> mp[111][2]; int pre; cin >> pre; mp[0][0].insert(pre); for (int i = 1; i <= N; i ++) { int x; if (i < N) cin >> x; else x = L; int d = x - pre; for (int p = 0; p < 2; p ++) { for (auto& k : mp[i - 1][p]) { for (int s = 0; s < 2; s ++) { int v = d + k; if (s) v = d - k; int q = p ^ s; mp[i][q].insert(v); } } } pre = x; } int ans = 1e9 + 7; for (auto k : mp[N][1]) { ans = min(ans, abs(k)); } cout << ans << endl; }