結果
| 問題 |
No.1231 Make a Multiple of Ten
|
| コンテスト | |
| ユーザー |
batsumaru
|
| 提出日時 | 2020-09-18 21:41:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 117 ms / 2,000 ms |
| コード長 | 878 bytes |
| コンパイル時間 | 1,693 ms |
| コンパイル使用メモリ | 172,248 KB |
| 実行使用メモリ | 28,312 KB |
| 最終ジャッジ日時 | 2024-06-23 13:41:08 |
| 合計ジャッジ時間 | 3,184 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())
template <class T>
inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main() {
ll n;
cin >> n;
vector<ll> a(n);
REP(i, n) { cin >> a[i]; }
vector<vector<ll>> dp(n + 1, vector<ll>(10, -1));
dp[0][0] = 0;
REP(i, n) REP(j, 10) {
if (dp[i][j] == -1) {
continue;
}
chmax(dp[i + 1][(j + a[i]) % 10], dp[i][j] + 1);
chmax(dp[i + 1][j], dp[i][j]);
}
cout << dp[n][0] << endl;
}
batsumaru