結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー |
|
提出日時 | 2020-09-18 21:45:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 109 ms / 2,000 ms |
コード長 | 602 bytes |
コンパイル時間 | 1,908 ms |
コンパイル使用メモリ | 195,764 KB |
最終ジャッジ日時 | 2025-01-14 16:50:06 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h>#define rep(i, n) for (int i = 0; i < (n); ++i)using namespace std;using ll = long long;ll dp[int(1e5) * 2 + 5][10];int main() {ll N;cin >> N;vector<ll> a(N);rep(i, N) {cin >> a[i];}rep(i, N + 1) rep(j, 10) {dp[i][j] = -1;}dp[0][0] = 0;rep(i, N) rep(j, 10) {if (dp[i][j] == -1) {continue;}dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);dp[i + 1][(j + a[i]) % 10] = max(dp[i + 1][(j + a[i]) % 10], dp[i][j] + 1);}cout << dp[N][0] << endl;return 0;}