結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー E31415926E31415926
提出日時 2019-08-31 16:11:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,046 bytes
コンパイル時間 2,372 ms
コンパイル使用メモリ 165,952 KB
実行使用メモリ 10,644 KB
最終ジャッジ日時 2023-09-06 11:58:05
合計ジャッジ時間 4,523 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 3 ms
8,436 KB
testcase_06 AC 3 ms
8,400 KB
testcase_07 AC 3 ms
8,352 KB
testcase_08 WA -
testcase_09 AC 3 ms
8,340 KB
testcase_10 AC 3 ms
8,396 KB
testcase_11 AC 3 ms
8,452 KB
testcase_12 AC 15 ms
8,660 KB
testcase_13 AC 3 ms
8,384 KB
testcase_14 AC 2 ms
8,348 KB
testcase_15 AC 3 ms
8,408 KB
testcase_16 AC 3 ms
8,352 KB
testcase_17 AC 3 ms
8,428 KB
testcase_18 AC 3 ms
8,580 KB
testcase_19 AC 2 ms
8,348 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 3 ms
8,292 KB
testcase_24 AC 3 ms
8,288 KB
testcase_25 AC 3 ms
8,364 KB
testcase_26 AC 2 ms
8,336 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 4 ms
8,392 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int dp[300300];
int minv[300300];
int maxv[300300];

signed main() {
    int N;
    cin >> N;
    fill(dp, dp + 300300, INF);
    dp[0] = 0;
    minv[0] = 0, maxv[0] = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; i - j * j >= 0; ++j) {
            if (dp[i] > dp[i - j * j] + j) {
                dp[i] = dp[i - j * j] + j;
                minv[i] = j;
                maxv[i] = j;
            } else if (dp[i] == dp[i - j * j] + j) {
                minv[i] = min(minv[i], j);
                maxv[i] = max(maxv[i], j);
            }
        }
    }
    string ans;
    int s = 0;
    while (N) {
        int j = s == 0 ? minv[N] : maxv[N];
        rep(i, j) {
            ans.push_back(s + '0');
            s = 1 - s;
        }
        s = 1 - s;
        N -= j * j;
    }
    cout << ans << endl;
    return 0;
}
0