結果

問題 No.2178 Payable Magic Items
ユーザー t98slidert98slider
提出日時 2023-01-07 00:35:37
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 4,000 ms
コード長 570 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 167,508 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-21 07:57:54
合計ジャッジ時間 5,002 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 17 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 67 ms
4,380 KB
testcase_12 AC 73 ms
4,380 KB
testcase_13 AC 73 ms
4,380 KB
testcase_14 AC 74 ms
4,376 KB
testcase_15 AC 74 ms
4,380 KB
testcase_16 AC 73 ms
4,384 KB
testcase_17 AC 35 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 17 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 56 ms
4,380 KB
testcase_25 AC 25 ms
4,380 KB
testcase_26 AC 22 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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