結果

問題 No.2142 Segment Zero
ユーザー milanis48663220milanis48663220
提出日時 2022-12-02 21:31:00
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 558 ms / 2,000 ms
コード長 1,619 bytes
コンパイル時間 1,222 ms
コンパイル使用メモリ 120,808 KB
実行使用メモリ 50,432 KB
最終ジャッジ日時 2024-04-18 05:15:19
合計ジャッジ時間 13,388 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 332 ms
50,304 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 329 ms
50,176 KB
testcase_04 AC 504 ms
50,432 KB
testcase_05 AC 502 ms
50,304 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 341 ms
50,176 KB
testcase_08 AC 558 ms
50,432 KB
testcase_09 AC 336 ms
50,304 KB
testcase_10 AC 552 ms
50,304 KB
testcase_11 AC 548 ms
50,432 KB
testcase_12 AC 550 ms
50,304 KB
testcase_13 AC 551 ms
50,176 KB
testcase_14 AC 550 ms
50,176 KB
testcase_15 AC 551 ms
50,304 KB
testcase_16 AC 548 ms
50,304 KB
testcase_17 AC 456 ms
42,368 KB
testcase_18 AC 68 ms
14,336 KB
testcase_19 AC 71 ms
12,928 KB
testcase_20 AC 290 ms
29,568 KB
testcase_21 AC 250 ms
32,896 KB
testcase_22 AC 390 ms
37,632 KB
testcase_23 AC 58 ms
13,056 KB
testcase_24 AC 98 ms
18,560 KB
testcase_25 AC 119 ms
21,248 KB
testcase_26 AC 235 ms
36,352 KB
testcase_27 AC 256 ms
37,888 KB
testcase_28 AC 235 ms
25,216 KB
testcase_29 AC 290 ms
29,184 KB
testcase_30 AC 384 ms
36,864 KB
testcase_31 AC 222 ms
35,968 KB
testcase_32 AC 110 ms
17,152 KB
testcase_33 AC 37 ms
9,856 KB
testcase_34 AC 123 ms
21,632 KB
testcase_35 AC 536 ms
49,152 KB
testcase_36 AC 103 ms
13,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll n, k; cin >> n >> k;
    ll sum = (n*(n+1))/2;
    ll rem = sum-k;
    set<ll> st;
    st.insert(0);
    ll s = 0;
    for(int i = 0; i < n; i++){
        s += i+1;
        st.insert(s);
    }
    for(ll x: st){
        if(st.count(rem+x)){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 2 << endl;
}
0