結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー | ゆきのん |
提出日時 | 2020-09-21 06:58:54 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 112 ms / 2,000 ms |
コード長 | 1,075 bytes |
コンパイル時間 | 2,655 ms |
コンパイル使用メモリ | 169,252 KB |
実行使用メモリ | 28,132 KB |
最終ジャッジ日時 | 2023-09-06 16:56:27 |
合計ジャッジ時間 | 3,123 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 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 | 53 ms
14,448 KB |
testcase_05 | AC | 46 ms
13,064 KB |
testcase_06 | AC | 19 ms
7,120 KB |
testcase_07 | AC | 55 ms
14,876 KB |
testcase_08 | AC | 23 ms
9,960 KB |
testcase_09 | AC | 12 ms
5,356 KB |
testcase_10 | AC | 49 ms
13,592 KB |
testcase_11 | AC | 59 ms
15,716 KB |
testcase_12 | AC | 106 ms
26,840 KB |
testcase_13 | AC | 111 ms
28,132 KB |
testcase_14 | AC | 2 ms
4,384 KB |
testcase_15 | AC | 112 ms
27,996 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(),A.end() #define RALL(A) A.rbegin(),A.rend() typedef long long ll; typedef pair<ll,ll> P; 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; } template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;} const ll MOD=1000000007; const ll LINF=1ll<<60; const int INF=1<<30; int dx[]={1,0,-1,0,1,-1,1,-1}; int dy[]={0,1,0,-1,1,-1,-1,1}; int main(){ int n;cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; a[i] %= 10; } vector<vector<ll>> dp(n+1,vector<ll> (10, -LINF)); dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < 10; j++) { 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; return 0; }