結果
問題 |
No.2142 Segment Zero
|
ユーザー |
![]() |
提出日時 | 2022-12-02 22:20:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 524 bytes |
コンパイル時間 | 1,604 ms |
コンパイル使用メモリ | 169,224 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-10-09 23:52:52 |
合計ジャッジ時間 | 3,183 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int64_t n, k; cin >> n >> k; vector<int64_t> s(n + 1); s[1] = 1; for(int64_t i = 2; i <= n; i++) s[i] = s[i - 1] + i; if(binary_search(s.begin(), s.end(), k)) { cout << 1 << endl; return 0; } const int64_t smax = n * (n + 1) / 2; int64_t r_sum = 0; for(int64_t i = n; i >= 2; i--) { r_sum += i; s.pop_back(); if(binary_search(s.begin(), s.end(), k - r_sum)) { cout << 1 << endl; return 0; } } cout << 2 << endl; return 0; }