結果

問題 No.2542 Yokan for Two
ユーザー ococonomy1ococonomy1
提出日時 2023-11-24 22:22:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,888 bytes
コンパイル時間 1,452 ms
コンパイル使用メモリ 129,668 KB
実行使用メモリ 382,208 KB
最終ジャッジ日時 2023-11-24 22:22:50
合計ジャッジ時間 7,786 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 313 ms
51,584 KB
testcase_04 AC 478 ms
83,840 KB
testcase_05 AC 1,566 ms
200,448 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 TLE -
testcase_08 AC 576 ms
78,208 KB
testcase_09 TLE -
testcase_10 AC 209 ms
36,736 KB
testcase_11 AC 334 ms
62,080 KB
testcase_12 AC 1,222 ms
156,288 KB
testcase_13 AC 169 ms
34,304 KB
testcase_14 AC 1,114 ms
170,368 KB
testcase_15 AC 1,520 ms
222,720 KB
testcase_16 AC 1,338 ms
203,904 KB
testcase_17 AC 1,124 ms
176,256 KB
testcase_18 AC 1,389 ms
209,536 KB
testcase_19 AC 596 ms
106,880 KB
testcase_20 AC 431 ms
82,304 KB
testcase_21 AC 508 ms
93,440 KB
testcase_22 AC 495 ms
92,288 KB
testcase_23 AC 602 ms
103,424 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 3 ms
6,676 KB
testcase_29 AC 427 ms
62,592 KB
testcase_30 AC 1,103 ms
170,496 KB
testcase_31 AC 1,110 ms
173,440 KB
testcase_32 AC 1,071 ms
168,192 KB
testcase_33 AC 1,221 ms
183,040 KB
testcase_34 AC 1,414 ms
207,872 KB
testcase_35 AC 1,488 ms
220,544 KB
testcase_36 AC 1,407 ms
207,872 KB
testcase_37 AC 1,498 ms
220,928 KB
testcase_38 AC 1,414 ms
210,048 KB
testcase_39 AC 1,613 ms
233,344 KB
testcase_40 AC 1,521 ms
221,824 KB
testcase_41 AC 1,451 ms
213,760 KB
testcase_42 AC 1,478 ms
214,912 KB
testcase_43 AC 1,475 ms
219,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <unordered_map>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
// #define AMARI 1000000007
#define TIME_LIMIT 1980000
#define el '\n'
#define El '\n'

#define MULTI_TEST_CASE false
void solve(void) {
    int l,n;
    cin >> l >> n;
    vector<int> x(n);
    vector<bool> kireme(l,false);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    x.push_back(l);
    n++;
    //dp0[i] := 赤側を選んでる時の、i番目の切れ目まで見た時のありえるA-Bの値の集合
    vector<set<int>> dp0(n + 1),dp1(n + 1);
    dp0[0].insert(0);
    for(int i = 0; i < n; i++){
        int dif = x[i] - (i == 0 ? 0 : x[i - 1]);
        for(set<int>::iterator it = dp0[i].begin(); it != dp0[i].end(); it++){
            dp0[i + 1].insert(*it + dif);
            if(i != 0)dp1[i + 1].insert(*it - dif);
        }
        for(set<int>::iterator it = dp1[i].begin(); it != dp1[i].end(); it++){
            dp0[i + 1].insert(*it + dif);
            dp1[i + 1].insert(*it - dif);
        }
    }
    int ans = INT_MAX;
    for(set<int>::iterator it = dp1[n].begin(); it != dp1[n].end(); it++){
        ans = min(ans,abs(*it));
    }
    cout << ans << el;
    return;
}

void calc(void) {
    return;
}

signed main(void) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE) cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}
0