結果
| 問題 | No.2142 Segment Zero |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-10 21:51:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 852 bytes |
| コンパイル時間 | 793 ms |
| コンパイル使用メモリ | 96,908 KB |
| 最終ジャッジ日時 | 2025-02-15 09:37:14 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 WA * 1 |
ソースコード
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
const double PI=acos(-1);
int main(){
ll N,K;
cin>>N>>K;
ll l=0,r=0;
ll sum=0;
if(K==N*(N+1)/2){
cout<<0<<endl;
return 0;
}
ll tot=N*(N+1)/2;
while(l<=N){
while(r<N && (tot-sum)>K){
sum+=r;
r++;
}
//(tot-sum)<=K || r==N
if((tot-sum)==K){
cout<<1<<endl;
return 0;
}
//r==Nのときは何もしない
//(tot-sum)<K
sum-=l;
l++;
}
cout<<2<<endl;
return 0;
}