結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー | bonKotsu |
提出日時 | 2020-12-28 18:00:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 100 ms / 2,000 ms |
コード長 | 591 bytes |
コンパイル時間 | 1,591 ms |
コンパイル使用メモリ | 167,880 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-10-03 08:42:09 |
合計ジャッジ時間 | 3,469 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair<int, int> int dp[200020][10]; void chmax(int& a, int b) { if (a < b) a = b; } int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a[i]; a[i] %= 10; } rep(i, n) { rep(j, 10) { dp[i][j] = -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; }