結果

問題 No.1231 Make a Multiple of Ten
ユーザー hamihami
提出日時 2021-11-30 22:23:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 797 bytes
コンパイル時間 1,447 ms
コンパイル使用メモリ 169,652 KB
実行使用メモリ 17,816 KB
最終ジャッジ日時 2023-09-16 20:03:10
合計ジャッジ時間 3,906 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 48 ms
9,908 KB
testcase_05 AC 42 ms
9,376 KB
testcase_06 AC 18 ms
5,532 KB
testcase_07 AC 49 ms
10,104 KB
testcase_08 AC 20 ms
7,196 KB
testcase_09 AC 11 ms
4,380 KB
testcase_10 AC 43 ms
9,364 KB
testcase_11 AC 52 ms
10,680 KB
testcase_12 AC 93 ms
16,896 KB
testcase_13 AC 99 ms
17,816 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 98 ms
17,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
using LL = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); ++i)
template<class T>void chmin(T&a, T b){if(a > b) a = b;}
template<class T>void chmax(T&a, T b){if(a < b) a = b;}


int main(){
	int N; cin >> N; 
	vector<int> A(N);
	for(int i = 0; i < N; ++i) cin >> A[i];

	vector<vector<int>> dp(N+1, vector<int>(10,0));
	for(int i = 0; i < N; ++i){
		if(dp[i][A[i]%10]==0) dp[i+1][A[i]%10] = 1;
		for(int j = 0; j < 10; ++j){
			if(dp[i][j]!=0){
				   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