結果
問題 | No.2142 Segment Zero |
ユーザー |
![]() |
提出日時 | 2022-12-02 21:46:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 540 ms / 2,000 ms |
コード長 | 463 bytes |
コンパイル時間 | 2,387 ms |
コンパイル使用メモリ | 197,208 KB |
最終ジャッジ日時 | 2025-02-09 03:42:44 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define INF 1234567890 #define ll long long ll N, K; int main() { ios::sync_with_stdio(0); cin.tie(0); cin.exceptions(ios::badbit | ios::failbit); cin >> N >> K; K = N*(N+1)/2 - K; // remove sum = K, minimize remove count assert(K > 0); set<ll> s; for(ll i=1; i<=N; i++) { s.insert((i-1)*i/2); if (s.find(i*(i+1)/2 - K) != s.end()) { cout << "1\n"; return 0; } } cout << "2\n"; return 0; }