結果

問題 No.2142 Segment Zero
ユーザー tree_splaytree_splay
提出日時 2022-12-02 21:46:07
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 530 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 207,252 KB
実行使用メモリ 50,432 KB
最終ジャッジ日時 2024-10-09 22:52:40
合計ジャッジ時間 11,232 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0