結果
問題 |
No.2142 Segment Zero
|
ユーザー |
👑 ![]() |
提出日時 | 2024-04-21 16:44:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 533 bytes |
コンパイル時間 | 913 ms |
コンパイル使用メモリ | 79,544 KB |
最終ジャッジ日時 | 2025-02-21 08:16:39 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> using namespace std; using i64 = long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); i64 N, K; cin >> N >> K; vector<i64> S(N+1); rep(i,N) S[i+1] = S[i] + (i+1); vector<i64> Q = S; sort(Q.begin(), Q.end()); int ans = 2; rep(i,N+1) if(binary_search(Q.begin(), Q.end(), K - (S[N] - S[i]))) ans = 1; cout << ans << '\n'; return 0; }