結果
| 問題 |
No.1231 Make a Multiple of Ten
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-18 21:57:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 995 bytes |
| コンパイル時間 | 764 ms |
| コンパイル使用メモリ | 88,316 KB |
| 最終ジャッジ日時 | 2025-01-14 17:07:31 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
// __
// / <@フ
// |(ノノハ))
// ノ从゚ヮ゚从
// ノ|ソノГ|つ 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";
}