結果
問題 | No.2142 Segment Zero |
ユーザー |
![]() |
提出日時 | 2022-12-03 17:27:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 555 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 41,672 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-10 20:05:58 |
合計ジャッジ時間 | 1,479 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
/* -*- coding: utf-8 -*- * * 2142.cc: No.2142 Segment Zero - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 1000000; /* typedef */ typedef long long ll; /* global variables */ /* subroutines */ /* main */ int main() { int n; ll k; scanf("%d%lld", &n, &k); ll r = (ll)n * (n + 1) / 2 - k; ll sum = 0; for (int i = 1, j = 1; i <= n; i++) { while (j <= n && sum < r) sum += j++; if (sum == r) { puts("1"); return 0; } sum -= i; } puts("2"); return 0; }