結果

問題 No.689 E869120 and Constructing Array 3
ユーザー どららどらら
提出日時 2018-05-19 00:26:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 2,171 ms
コンパイル使用メモリ 176,104 KB
実行使用メモリ 4,696 KB
最終ジャッジ日時 2023-09-10 23:29:22
合計ジャッジ時間 5,692 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


map<ll,vector<int>> memo;

void make(){
  REP(N,1,251){
    rep(a,N+1){
      rep(b,N+1-a){
        int c = N-(a+b);
        if(c < 0) continue;
        
        int sum = a*(a-1) + a*b + b*c;
        if(0<=sum && sum<=10000){
          memo[sum] = {a,b,c};
          if(memo.size() == 10000) return;
        }
        if(sum >= 10000) break;
      }
    }
  }
}

int main(){
  int K;
  cin >> K;
  make();

  vector<int> ret = memo[K];
  cout << ret[0] + ret[1] + ret[2] << endl;
  vector<int> res;
  rep(i,ret[0]) res.push_back(1);
  rep(i,ret[1]) res.push_back(2);
  rep(i,ret[2]) res.push_back(3);

  rep(i,res.size()){
    if(i>0) cout << " ";
    cout << res[i];
  }
  
  return 0;
}
0