結果
問題 | No.689 E869120 and Constructing Array 3 |
ユーザー |
![]() |
提出日時 | 2018-05-05 17:18:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 616 bytes |
コンパイル時間 | 650 ms |
コンパイル使用メモリ | 69,628 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 13:34:38 |
合計ジャッジ時間 | 1,830 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <vector>#include <iostream>using namespace std;// Proved: (the size of sequence) <= 159int 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;}