結果

問題 No.1231 Make a Multiple of Ten
ユーザー itohdakitohdak
提出日時 2020-09-18 21:42:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 957 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 203,116 KB
実行使用メモリ 28,068 KB
最終ジャッジ日時 2023-09-05 18:12:43
合計ジャッジ時間 3,529 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 31 ms
14,312 KB
testcase_05 AC 27 ms
13,028 KB
testcase_06 AC 12 ms
6,976 KB
testcase_07 AC 32 ms
15,000 KB
testcase_08 AC 17 ms
9,976 KB
testcase_09 AC 7 ms
5,440 KB
testcase_10 AC 29 ms
13,836 KB
testcase_11 AC 34 ms
15,620 KB
testcase_12 AC 61 ms
26,744 KB
testcase_13 AC 63 ms
28,068 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 64 ms
27,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  vector<vector<ll>> dp(n+1, vector<ll>(10, -longinf));
  dp[0][0] = 0;
  rep(i, n) {
    rep(j, 10) {
      chmax(dp[i+1][j], dp[i][j]);
      chmax(dp[i+1][(j+A[i])%10], dp[i][j]+1);
    }
  }
  cout << dp[n][0] << endk;
  return 0;
}
0