結果
問題 | No.689 E869120 and Constructing Array 3 |
ユーザー |
|
提出日時 | 2018-05-18 22:54:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 688 bytes |
コンパイル時間 | 1,617 ms |
コンパイル使用メモリ | 169,116 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 13:57:14 |
合計ジャッジ時間 | 2,869 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define ll long longvoid print_ans(int a, int b, int c) {cout << (a+b+c) << endl;vector<int> v;for(int i=0; i<a; i++) v.push_back(1);for(int i=0; i<b; i++) v.push_back(2);for(int i=0; i<c; i++) v.push_back(3);for(int i=0; i<v.size(); i++) {if(i==0) {cout << v.at(i);} else {cout << " " << v.at(i);}}cout << endl;}int main() {int k;cin >> k;for(int n=1; n<=250; n++) {for(int a=0; a<=n; a++) {for(int b=0; b<=n-a; b++) {int c = n-a-b;int t = a*b+b*c;if(a>=2) t += a*(a-1)/2;if(t==k) {print_ans(a, b, c);return 0;}}}}return 0;}