結果

問題 No.2142 Segment Zero
ユーザー t98slidert98slider
提出日時 2022-12-02 21:31:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 164,868 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-18 05:15:48
合計ジャッジ時間 3,011 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 5 ms
10,904 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 7 ms
11,008 KB
testcase_04 AC 56 ms
11,104 KB
testcase_05 AC 53 ms
10,904 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 10 ms
10,968 KB
testcase_08 AC 31 ms
11,008 KB
testcase_09 AC 6 ms
10,880 KB
testcase_10 AC 28 ms
11,104 KB
testcase_11 AC 29 ms
11,008 KB
testcase_12 AC 30 ms
11,008 KB
testcase_13 AC 28 ms
11,008 KB
testcase_14 AC 27 ms
11,128 KB
testcase_15 AC 27 ms
11,008 KB
testcase_16 AC 28 ms
11,136 KB
testcase_17 AC 23 ms
9,748 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 6 ms
5,376 KB
testcase_20 AC 16 ms
7,552 KB
testcase_21 AC 18 ms
8,064 KB
testcase_22 AC 21 ms
8,832 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,760 KB
testcase_25 AC 4 ms
6,272 KB
testcase_26 AC 7 ms
8,576 KB
testcase_27 AC 9 ms
9,048 KB
testcase_28 AC 15 ms
6,912 KB
testcase_29 AC 16 ms
7,552 KB
testcase_30 AC 20 ms
8,832 KB
testcase_31 AC 4 ms
8,620 KB
testcase_32 AC 9 ms
5,504 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 5 ms
6,400 KB
testcase_35 AC 27 ms
10,764 KB
testcase_36 AC 9 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, K;
    cin >> N >> K;
    vector<ll> s(N + 1);
    iota(s.begin(), s.end(), 0);
    for(int i = 0; i < N; i++){
        s[i + 1] += s[i];
    }
    if(s.back() == K){
        cout << 0 << '\n';
        return 0;
    }
    ll rem = s.back() - K;
    for(int i = 0; i < N; i++){
        if(binary_search(s.begin(), s.end(), s[i] + rem)){
            cout << 1 << '\n';
            return 0;
        }
    }
    cout << 2 << '\n';
}
0