結果

問題 No.1231 Make a Multiple of Ten
ユーザー batsumarubatsumaru
提出日時 2020-09-18 21:41:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 878 bytes
コンパイル時間 1,760 ms
コンパイル使用メモリ 170,240 KB
実行使用メモリ 28,044 KB
最終ジャッジ日時 2023-09-05 18:12:04
合計ジャッジ時間 3,290 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 54 ms
14,532 KB
testcase_05 AC 47 ms
13,016 KB
testcase_06 AC 19 ms
6,940 KB
testcase_07 AC 57 ms
14,860 KB
testcase_08 AC 23 ms
10,048 KB
testcase_09 AC 12 ms
5,408 KB
testcase_10 AC 50 ms
13,548 KB
testcase_11 AC 60 ms
15,852 KB
testcase_12 AC 108 ms
26,756 KB
testcase_13 AC 113 ms
28,020 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 115 ms
28,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0