結果

問題 No.2542 Yokan for Two
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-11-24 21:42:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,630 ms / 2,000 ms
コード長 581 bytes
コンパイル時間 2,378 ms
コンパイル使用メモリ 206,776 KB
実行使用メモリ 350,056 KB
最終ジャッジ日時 2023-11-24 21:42:52
合計ジャッジ時間 25,243 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 196 ms
47,788 KB
testcase_04 AC 308 ms
77,440 KB
testcase_05 AC 859 ms
179,196 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 1,630 ms
350,056 KB
testcase_08 AC 332 ms
70,456 KB
testcase_09 AC 1,577 ms
323,184 KB
testcase_10 AC 125 ms
33,760 KB
testcase_11 AC 230 ms
55,808 KB
testcase_12 AC 654 ms
139,628 KB
testcase_13 AC 117 ms
31,488 KB
testcase_14 AC 586 ms
153,088 KB
testcase_15 AC 831 ms
202,584 KB
testcase_16 AC 722 ms
185,128 KB
testcase_17 AC 649 ms
160,120 KB
testcase_18 AC 745 ms
190,376 KB
testcase_19 AC 367 ms
97,792 KB
testcase_20 AC 266 ms
74,752 KB
testcase_21 AC 308 ms
85,504 KB
testcase_22 AC 300 ms
82,560 KB
testcase_23 AC 339 ms
92,544 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 265 ms
57,268 KB
testcase_30 AC 648 ms
153,344 KB
testcase_31 AC 631 ms
156,284 KB
testcase_32 AC 608 ms
151,936 KB
testcase_33 AC 690 ms
164,700 KB
testcase_34 AC 784 ms
189,632 KB
testcase_35 AC 852 ms
199,888 KB
testcase_36 AC 765 ms
187,644 KB
testcase_37 AC 833 ms
202,164 KB
testcase_38 AC 847 ms
193,260 KB
testcase_39 AC 848 ms
213,056 KB
testcase_40 AC 833 ms
204,092 KB
testcase_41 AC 776 ms
196,516 KB
testcase_42 AC 786 ms
197,516 KB
testcase_43 AC 789 ms
201,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main () {
	int L, N;
	cin >> L >> N;
	unordered_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;
}
0