結果

問題 No.2142 Segment Zero
ユーザー lddlinanlddlinan
提出日時 2023-03-19 18:05:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 801 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 90,996 KB
実行使用メモリ 49,952 KB
最終ジャッジ日時 2023-10-18 17:51:50
合計ジャッジ時間 9,103 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 335 ms
49,952 KB
testcase_05 AC 332 ms
49,952 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 546 ms
49,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 538 ms
49,948 KB
testcase_15 WA -
testcase_16 AC 540 ms
49,940 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 49 ms
11,128 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 6 ms
4,348 KB
testcase_24 AC 12 ms
5,152 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 275 ms
28,816 KB
testcase_30 AC 363 ms
36,524 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 11 ms
5,088 KB
testcase_34 WA -
testcase_35 AC 536 ms
48,732 KB
testcase_36 AC 89 ms
13,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
    bool operator()(const int& a, const int& b) {
        return a<b;
    }
};



int main() {
    int n, i;
    LL k, s, ss;
    scanf("%d %lld", &n, &k);
    ss=n; ss*=(1+n); ss/=2;
    set<LL> vs;
    s=0; for (i=1; i<=n; i++) {
        s+=i; ss-=i;
        if (s==k||ss==k) break;
        if (s>k&&vs.count(s-k)) break;
        vs.insert(s);
    }
    if (i<=n) printf("1\n"); else {
        printf("2\n");
    }
    return 0;
}
0