結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー | k |
提出日時 | 2020-12-11 21:01:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 519 bytes |
コンパイル時間 | 2,391 ms |
コンパイル使用メモリ | 195,764 KB |
最終ジャッジ日時 | 2025-01-16 22:25:44 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> a(n); REP (i, n) { cin >> a[i]; a[i] %= 10; } vector<int> dp(10, -1); dp[0] = 0; REP (i, n) { vector<int> dq = dp; REP (j, 10) { if (dp[j] != -1) { int k = (j + a[i]) % 10; dq[k] = max(dp[k], dp[j] + 1); } } dp = dq; } cout << dp[0] << endl; return 0; }