結果

問題 No.689 E869120 and Constructing Array 3
ユーザー e869120e869120
提出日時 2018-05-04 22:01:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 602 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 65,924 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 22:40:21
合計ジャッジ時間 2,726 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <tuple>
using namespace std;

int N, A[1009], K;

int main() {
	cin >> K; int minx = 10000;
	for (int i = 0; i <= 140; i++) {
		for (int j = 0; j <= 140; j++) {
			for (int k = 0; k <= 140; k++) {
				if (j*k + i*(i - 1) / 2 != K) continue;

				if (minx > i + j + k) {
					minx = i + j + k;
					for (int l = 0; l < i; l++) A[l] = 1;
					for (int l = i; l < i + j; l++) A[l] = 3;
					for (int l = i + j; l < i + j + k; l++) A[l] = 8;
				}
			}
		}
	}
	cout << minx << endl;
	for (int i = 0; i < minx; i++) { if (i)cout << " "; cout << A[i]; }cout << endl;
	return 0;
}
0