結果

問題 No.2178 Payable Magic Items
ユーザー t98slidert98slider
提出日時 2023-01-07 00:30:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 4,000 ms
コード長 643 bytes
コンパイル時間 1,447 ms
コンパイル使用メモリ 168,296 KB
実行使用メモリ 4,840 KB
最終ジャッジ日時 2023-08-21 07:59:09
合計ジャッジ時間 3,220 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,648 KB
testcase_01 AC 3 ms
4,576 KB
testcase_02 AC 3 ms
4,560 KB
testcase_03 AC 23 ms
4,840 KB
testcase_04 AC 4 ms
4,640 KB
testcase_05 AC 3 ms
4,572 KB
testcase_06 AC 4 ms
4,572 KB
testcase_07 AC 3 ms
4,584 KB
testcase_08 AC 4 ms
4,632 KB
testcase_09 AC 4 ms
4,624 KB
testcase_10 AC 3 ms
4,648 KB
testcase_11 AC 35 ms
4,632 KB
testcase_12 AC 42 ms
4,636 KB
testcase_13 AC 42 ms
4,572 KB
testcase_14 AC 43 ms
4,716 KB
testcase_15 AC 42 ms
4,696 KB
testcase_16 AC 42 ms
4,652 KB
testcase_17 AC 30 ms
4,568 KB
testcase_18 AC 3 ms
4,564 KB
testcase_19 AC 11 ms
4,640 KB
testcase_20 AC 4 ms
4,560 KB
testcase_21 AC 3 ms
4,576 KB
testcase_22 AC 4 ms
4,716 KB
testcase_23 AC 3 ms
4,572 KB
testcase_24 AC 37 ms
4,564 KB
testcase_25 AC 26 ms
4,564 KB
testcase_26 AC 13 ms
4,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> dp(390625);
    vector<bool> dp2(390625);
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        int v = stoi(s, nullptr, 5);
        dp[v] = dp2[v] = 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] = 0;
            }
        }
    }
    cout << n - ans << '\n';
}
0