結果
| 問題 | No.2542 Yokan for Two | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-11-24 21:42:17 | 
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 581 bytes | 
| コンパイル時間 | 7,581 ms | 
| コンパイル使用メモリ | 257,836 KB | 
| 最終ジャッジ日時 | 2025-02-17 23:55:58 | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 38 TLE * 2 | 
ソースコード
#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;
}
            
            
            
        