結果

問題 No.689 E869120 and Constructing Array 3
コンテスト
ユーザー vjudge1
提出日時 2025-11-16 12:42:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 798 bytes
コンパイル時間 1,355 ms
コンパイル使用メモリ 157,980 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-16 12:42:51
合計ジャッジ時間 2,998 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
signed main()
{
  
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;

    for (int i = 0; i <= 250; ++i)
        for (int j = 0; j <= 250 && i + j <= 250; ++j)
            for (int k = 0; k <= 250 && i + j + k <= 250; ++k)
                if (i * (i - 1) / 2 + i * j + j * k == n)
                {
                    cout << i + j + k << "\n";
                    for (int sb = 1; sb <= i; sb++)
                        cout << 1 << " ";
                    for (int sb = 1; sb <= j; sb++)
                        cout << 2 << " ";
                    for (int sb = 1; sb <= k; sb++)
                        cout << 3 << " ";
                    return 0;
                }
}
0