結果
| 問題 |
No.1231 Make a Multiple of Ten
|
| コンテスト | |
| ユーザー |
iqueue02
|
| 提出日時 | 2020-09-18 22:25:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 103 ms / 2,000 ms |
| コード長 | 586 bytes |
| コンパイル時間 | 2,232 ms |
| コンパイル使用メモリ | 196,528 KB |
| 最終ジャッジ日時 | 2025-01-14 17:25:55 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 1e9;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i,n) cin >> a[i];
vector<int> dp(10, -1);
dp[0] = 0;
for (int i = 0; i < n; i++) {
auto ndp = dp;
for (int j = 0; j < 10; j++) {
if (dp[j] == -1) continue;
ndp[(j + a[i]) % 10] = max(dp[(j + a[i]) % 10], dp[j] + 1);
}
dp = move(ndp);
}
cout << dp[0] << endl;
return 0;
}
iqueue02