結果

問題 No.1231 Make a Multiple of Ten
ユーザー bonKotsubonKotsu
提出日時 2020-12-28 18:00:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 1,575 ms
コンパイル使用メモリ 165,424 KB
実行使用メモリ 11,856 KB
最終ジャッジ日時 2024-04-14 11:39:07
合計ジャッジ時間 4,082 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 48 ms
8,372 KB
testcase_05 AC 41 ms
7,076 KB
testcase_06 AC 18 ms
6,940 KB
testcase_07 AC 50 ms
7,848 KB
testcase_08 AC 18 ms
6,940 KB
testcase_09 AC 12 ms
6,940 KB
testcase_10 AC 44 ms
8,552 KB
testcase_11 AC 53 ms
9,232 KB
testcase_12 AC 99 ms
11,348 KB
testcase_13 AC 101 ms
11,760 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 100 ms
11,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>

int dp[200020][10];

void chmax(int& a, int b) {
  if (a < b) a = b;
}

int main() {
  int n;
  cin >> n;

  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] %= 10;
  }

rep(i, n) {
  rep(j, 10) {
    dp[i][j] = -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