結果

問題 No.689 E869120 and Constructing Array 3
ユーザー square1001square1001
提出日時 2018-05-05 17:18:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 616 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 69,292 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 22:40:33
合計ジャッジ時間 2,225 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
using namespace std;
// Proved: (the size of sequence) <= 159
int main() {
	int N;
	cin >> N;
	int a = 1;
	while (a * (a - 1) / 2 < N) a++;
	int b = 1;
	while (b * (b - 1) / 2 < a * (a - 1) / 2 - N) b++;
	int rem = N - a * (a - 1) / 2 + b * (b - 1) / 2;
	vector<int> ret;
	for (int i = 0; i < a - b; i++) ret.push_back(1);
	for (int i = 0; i < b; i++) ret.push_back(2);
	ret.push_back(7);
	for (int i = 0; i < rem; i++) ret.push_back(24);
	cout << ret.size() << '\n';
	for (int i = 0; i < ret.size(); i++) {
		if (i) cout << ' ';
		cout << ret[i];
	}
	cout << '\n';
	return 0;
}
0