結果

問題 No.1231 Make a Multiple of Ten
ユーザー YamaKasa
提出日時 2020-09-18 22:09:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 726 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 167,040 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 09:48:11
合計ジャッジ時間 2,596 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int A[N];
    int b[10]{};
    int s = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        b[A[i] % 10]++;
        s += A[i] % 10;
        s %= 10;
    }

    
    int d[10]{};
    fill(d, d + 10, 10000);
    d[0] = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k <= b[i]; k++) {
                int t = j + i * k;
                if (t >= 10) break;
                d[t] = min(d[t], d[j] + k);
            }
        }
    }
    
    if (s == 0) {
        cout << N << "\n";
    } else {
        cout << N - d[s] << "\n";
    }
    return 0;
}
0