結果

問題 No.2142 Segment Zero
ユーザー moririn2528_cmoririn2528_c
提出日時 2022-12-02 21:39:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 527 ms / 2,000 ms
コード長 2,205 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 127,104 KB
実行使用メモリ 50,352 KB
最終ジャッジ日時 2023-07-31 04:29:18
合計ジャッジ時間 11,334 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 409 ms
50,196 KB
testcase_02 AC 1 ms
4,388 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 527 ms
50,352 KB
testcase_05 AC 524 ms
50,248 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 107 ms
17,120 KB
testcase_08 AC 424 ms
50,280 KB
testcase_09 AC 253 ms
33,032 KB
testcase_10 AC 418 ms
50,288 KB
testcase_11 AC 419 ms
50,324 KB
testcase_12 AC 417 ms
50,348 KB
testcase_13 AC 409 ms
50,184 KB
testcase_14 AC 413 ms
50,188 KB
testcase_15 AC 414 ms
50,232 KB
testcase_16 AC 409 ms
50,280 KB
testcase_17 AC 332 ms
42,328 KB
testcase_18 AC 10 ms
4,972 KB
testcase_19 AC 50 ms
10,160 KB
testcase_20 AC 208 ms
29,452 KB
testcase_21 AC 172 ms
23,392 KB
testcase_22 AC 282 ms
37,492 KB
testcase_23 AC 65 ms
13,036 KB
testcase_24 AC 113 ms
18,556 KB
testcase_25 AC 64 ms
12,212 KB
testcase_26 AC 203 ms
28,108 KB
testcase_27 AC 108 ms
17,140 KB
testcase_28 AC 170 ms
25,148 KB
testcase_29 AC 214 ms
29,156 KB
testcase_30 AC 287 ms
36,768 KB
testcase_31 AC 9 ms
4,756 KB
testcase_32 AC 87 ms
14,656 KB
testcase_33 AC 41 ms
9,260 KB
testcase_34 AC 88 ms
15,156 KB
testcase_35 AC 400 ms
48,988 KB
testcase_36 AC 79 ms
13,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<complex>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
template<typename T> ostream& operator<<(ostream& os,const vector<T>& v1){
    int n=v1.size();
    for(int i=0;i<n;i++){
        if(i)os<<" ";
        os<<v1[i];
    }
    return os;
}
template<typename T1,typename T2> ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    os<<p.first<<" "<<p.second;
    return os;
}
template<typename T> istream& operator>>(istream& is,vector<T>& v1){
    int n=v1.size();
    for(int i=0;i<n;i++)is>>v1[i];
    return is;
}
template<typename T1,typename T2> istream& operator>>(istream& is,pair<T1,T2>& p){
    is>>p.first>>p.second;
    return is;
}

namespace sol{

    void solve(){
        LL n,m;
        LL i,j,k;
        LL a,b,c;
        cin>>n>>m;
        set<LL> s1;
        s1.insert(0);
        m=(n+1)*n/2-m;
        for(i=0;i<n;i++){
            a=(i+1)*(i+2)/2;
            s1.insert(a);
            if(s1.find(a-m)!=s1.end()){
                cout<<1<<endl;
                return;
            }
        }
        cout<<2<<endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sol::solve();
}
0