結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー | poohbear |
提出日時 | 2020-09-18 21:47:53 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 880 bytes |
コンパイル時間 | 2,025 ms |
コンパイル使用メモリ | 201,328 KB |
実行使用メモリ | 20,372 KB |
最終ジャッジ日時 | 2023-09-05 18:17:54 |
合計ジャッジ時間 | 3,564 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
18,948 KB |
testcase_01 | AC | 7 ms
19,004 KB |
testcase_02 | AC | 7 ms
19,236 KB |
testcase_03 | AC | 7 ms
19,160 KB |
testcase_04 | AC | 46 ms
19,236 KB |
testcase_05 | AC | 41 ms
19,276 KB |
testcase_06 | AC | 20 ms
19,104 KB |
testcase_07 | AC | 47 ms
19,564 KB |
testcase_08 | AC | 21 ms
18,948 KB |
testcase_09 | AC | 15 ms
19,252 KB |
testcase_10 | AC | 44 ms
19,348 KB |
testcase_11 | AC | 51 ms
19,460 KB |
testcase_12 | AC | 87 ms
20,136 KB |
testcase_13 | AC | 91 ms
20,372 KB |
testcase_14 | AC | 8 ms
19,020 KB |
testcase_15 | AC | 91 ms
20,348 KB |
ソースコード
#include <bits/stdc++.h> #define rep(a,n) for (ll a = 0; a < (n); ++a) using namespace std; //using namespace atcoder; using ll = long long; typedef pair<ll,ll> P; typedef pair<ll,P> PP; typedef vector<vector<int> > Graph; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e18; ll dp[200020][10]; int main(){ ll n; cin >> n; vector<ll>a(n); rep(i,n){ cin>>a[i]; a[i]%=10; } rep(i,200020)rep(j,10)dp[i][j]=-1; dp[0][0]=0; for(int i=1;i<=n;i++){ rep(j,10){ chmax(dp[i][j],dp[i-1][j]); if(dp[i-1][(j+10-a[i-1])%10]==-1)continue; chmax(dp[i][j],dp[i-1][(j+10-a[i-1])%10]+1); } } cout << dp[n][0] << endl; return 0; }