結果

問題 No.2178 Payable Magic Items
ユーザー t98slidert98slider
提出日時 2023-01-07 00:42:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 4,000 ms
コード長 453 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 166,668 KB
実行使用メモリ 4,896 KB
最終ジャッジ日時 2023-08-21 07:57:58
合計ジャッジ時間 3,404 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,608 KB
testcase_01 AC 3 ms
4,728 KB
testcase_02 AC 3 ms
4,632 KB
testcase_03 AC 15 ms
4,584 KB
testcase_04 AC 3 ms
4,736 KB
testcase_05 AC 3 ms
4,868 KB
testcase_06 AC 3 ms
4,676 KB
testcase_07 AC 3 ms
4,580 KB
testcase_08 AC 3 ms
4,624 KB
testcase_09 AC 4 ms
4,584 KB
testcase_10 AC 3 ms
4,580 KB
testcase_11 AC 68 ms
4,572 KB
testcase_12 AC 72 ms
4,616 KB
testcase_13 AC 72 ms
4,612 KB
testcase_14 AC 73 ms
4,740 KB
testcase_15 AC 72 ms
4,620 KB
testcase_16 AC 70 ms
4,572 KB
testcase_17 AC 33 ms
4,624 KB
testcase_18 AC 3 ms
4,896 KB
testcase_19 AC 17 ms
4,668 KB
testcase_20 AC 2 ms
4,584 KB
testcase_21 AC 3 ms
4,676 KB
testcase_22 AC 4 ms
4,576 KB
testcase_23 AC 3 ms
4,632 KB
testcase_24 AC 56 ms
4,672 KB
testcase_25 AC 23 ms
4,568 KB
testcase_26 AC 22 ms
4,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> dp(390625);
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        dp[stoi(s, nullptr, 5)] = 3;
    }
    for(int i = 390624; i >= 0; i--){
        if(!dp[i])continue;
        n -= dp[i] & 1;
        for(int j = 0, d = 1; j < k; j++, d *= 5){
            if(i / d % 5) dp[i - d] = 2;
        }
    }
    cout << n << '\n';
}
0