結果

問題 No.2142 Segment Zero
ユーザー Kome_soudouKome_soudou
提出日時 2022-12-02 22:20:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 1,853 ms
コンパイル使用メモリ 164,508 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-18 06:41:06
合計ジャッジ時間 3,714 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 9 ms
11,008 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 37 ms
11,136 KB
testcase_04 AC 39 ms
11,008 KB
testcase_05 AC 40 ms
11,008 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 13 ms
11,136 KB
testcase_08 AC 28 ms
11,008 KB
testcase_09 AC 10 ms
11,008 KB
testcase_10 AC 27 ms
11,008 KB
testcase_11 AC 28 ms
11,008 KB
testcase_12 AC 27 ms
11,136 KB
testcase_13 AC 27 ms
11,136 KB
testcase_14 AC 27 ms
11,136 KB
testcase_15 AC 28 ms
11,136 KB
testcase_16 AC 27 ms
11,008 KB
testcase_17 AC 23 ms
9,856 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 7 ms
5,376 KB
testcase_20 AC 15 ms
7,552 KB
testcase_21 AC 7 ms
8,064 KB
testcase_22 AC 20 ms
8,960 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 4 ms
5,760 KB
testcase_25 AC 8 ms
6,144 KB
testcase_26 AC 12 ms
8,832 KB
testcase_27 AC 10 ms
8,960 KB
testcase_28 AC 13 ms
6,784 KB
testcase_29 AC 16 ms
7,552 KB
testcase_30 AC 21 ms
8,832 KB
testcase_31 AC 18 ms
8,576 KB
testcase_32 AC 6 ms
5,504 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 5 ms
6,400 KB
testcase_35 AC 27 ms
10,880 KB
testcase_36 AC 9 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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