結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー |
|
提出日時 | 2020-09-18 21:55:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 562 bytes |
コンパイル時間 | 703 ms |
コンパイル使用メモリ | 72,808 KB |
最終ジャッジ日時 | 2025-01-14 17:05:10 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <iostream>#include <vector>constexpr int INF = 1 << 30;void solve() {int n;std::cin >> n;std::vector<int> dp(10, -INF);dp[0] = 0;while (n--) {int x;std::cin >> x;x %= 10;auto ndp = dp;for (int y = 0; y < 10; ++y) {ndp[(x + y) % 10] = std::max(ndp[(x + y) % 10], dp[y] + 1);}std::swap(dp, ndp);}std::cout << dp[0] << "\n";}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);solve();return 0;}