結果

問題 No.689 E869120 and Constructing Array 3
ユーザー どららどらら
提出日時 2018-05-19 00:30:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 1,000 ms
コード長 1,048 bytes
コンパイル時間 1,878 ms
コンパイル使用メモリ 175,784 KB
実行使用メモリ 4,700 KB
最終ジャッジ日時 2023-09-10 23:29:40
合計ジャッジ時間 4,704 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
4,472 KB
testcase_01 AC 78 ms
4,496 KB
testcase_02 AC 79 ms
4,416 KB
testcase_03 AC 79 ms
4,504 KB
testcase_04 AC 78 ms
4,588 KB
testcase_05 AC 78 ms
4,524 KB
testcase_06 AC 79 ms
4,448 KB
testcase_07 AC 79 ms
4,464 KB
testcase_08 AC 78 ms
4,412 KB
testcase_09 AC 81 ms
4,424 KB
testcase_10 AC 79 ms
4,412 KB
testcase_11 AC 78 ms
4,480 KB
testcase_12 AC 78 ms
4,472 KB
testcase_13 AC 80 ms
4,400 KB
testcase_14 AC 81 ms
4,700 KB
testcase_15 AC 89 ms
4,412 KB
権限があれば一括ダウンロードができます

ソースコード

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)/2 + a*b + b*c;
        if(0<=sum && sum<=10000){
          if(memo.count(sum) == 0)
            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];
  }
  cout << endl;
  
  return 0;
}
0