結果

問題 No.689 E869120 and Constructing Array 3
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2018-05-19 00:02:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,246 bytes
コンパイル時間 1,926 ms
コンパイル使用メモリ 167,996 KB
実行使用メモリ 814,336 KB
最終ジャッジ日時 2023-09-10 23:25:43
合計ジャッジ時間 5,989 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘void _main()’ 内:
main.cpp:2:33: 警告: ‘y’ may be used uninitialized [-Wmaybe-uninitialized]
    2 | #define rep(i,a,b) for(int i=a;i<b;i++)
      |                                 ^
main.cpp:65:16: 備考: ‘y’ はここで定義されています
   65 |         int x, y;
      |                ^
main.cpp:2:33: 警告: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
    2 | #define rep(i,a,b) for(int i=a;i<b;i++)
      |                                 ^
main.cpp:65:13: 備考: ‘x’ はここで定義されています
   65 |         int x, y;
      |             ^
main.cpp:2:33: 警告: ‘y’ may be used uninitialized [-Wmaybe-uninitialized]
    2 | #define rep(i,a,b) for(int i=a;i<b;i++)
      |                                 ^
main.cpp:48:12: 備考: ‘y’ はここで定義されています
   48 |     int x, y;
      |            ^
main.cpp:2:33: 警告: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
    2 | #define rep(i,a,b) for(int i=a;i<b;i++)
      |                                 ^
main.cpp:48:9: 備考: ‘x’ はここで定義されています
   48 |     int x, y;
      |         ^

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/


/*

K=0     4
  1     4 9
  2     4 9 9
  3     4 9 9 9
  4     4 


  4 9
  6 11
  8 21
*/




int K;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> K;

    vector<int> ans;

    int ma = -1;
    int x, y;
    rep(a, 1, K + 1) {
        int b = K / a;
        if (a + b <= 100) {
            if (chmax(ma, a * b)) {
                x = a;
                y = b;
            }
        }
    }

    K -= ma;
    rep(i, 0, x) ans.push_back(4);
    rep(i, 0, y) ans.push_back(9);

    if (K) {
        int mi = inf;
        int x, y;
        rep(a, 1, K + 1) if(K % a == 0) {
            int b = K / a;
            if (chmin(mi, a + b)) {
                x = a;
                y = b;
            }
        }

        rep(i, 0, x) ans.push_back(6);
        rep(i, 0, y) ans.push_back(11);
    }

    int n = ans.size();
    printf("%d\n", n);
    rep(i, 0, n) {
        if (i) printf(" ");
        printf("%d", ans[i]);
    }
    printf("\n");

}
0