結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー | hotaru |
提出日時 | 2020-09-18 21:57:11 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 995 bytes |
コンパイル時間 | 855 ms |
コンパイル使用メモリ | 86,508 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 13:47:30 |
合計ジャッジ時間 | 1,847 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 14 ms
6,944 KB |
testcase_05 | AC | 12 ms
6,940 KB |
testcase_06 | AC | 6 ms
6,940 KB |
testcase_07 | AC | 14 ms
6,940 KB |
testcase_08 | AC | 7 ms
6,940 KB |
testcase_09 | AC | 4 ms
6,944 KB |
testcase_10 | AC | 13 ms
6,944 KB |
testcase_11 | AC | 16 ms
6,940 KB |
testcase_12 | AC | 27 ms
6,940 KB |
testcase_13 | AC | 29 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 29 ms
6,944 KB |
ソースコード
// __ // / <@フ // |(ノノハ)) // ノ从゚ヮ゚从 // ノ|ソノГ|つ author:hotarunx // 〈_ノ^^^ヽ| // ~~tァtァ~ #include <algorithm> #include <array> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define int long long constexpr int INF = 1000000000 + 8; // DP signed main() { cin.tie(0); ios::sync_with_stdio(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; // dp[i]: // カードに書かれた整数の総和が10の倍数+iとなるようにカードを選ぶとき、選ぶカードの最大枚数 array<int, 10> dp; dp.fill(-INF); dp[0] = 0; for (auto &&ai : a) { array<int, 10> ndp; for (int i = 0; i < 10; i++) { ndp[i] = max(dp[i], dp[(10 + i - (ai % 10)) % 10] + 1); } dp = ndp; } cout << dp[0] << "\n"; }