結果

問題 No.1231 Make a Multiple of Ten
ユーザー chocoruskchocorusk
提出日時 2020-09-18 21:26:46
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 928 bytes
コンパイル時間 1,059 ms
コンパイル使用メモリ 126,624 KB
実行使用メモリ 11,280 KB
最終ジャッジ日時 2023-09-05 18:08:20
合計ジャッジ時間 2,515 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,468 KB
testcase_01 AC 3 ms
9,556 KB
testcase_02 AC 3 ms
9,512 KB
testcase_03 AC 2 ms
7,476 KB
testcase_04 AC 40 ms
9,184 KB
testcase_05 AC 36 ms
9,308 KB
testcase_06 AC 16 ms
9,760 KB
testcase_07 AC 42 ms
10,280 KB
testcase_08 AC 16 ms
10,056 KB
testcase_09 AC 10 ms
9,660 KB
testcase_10 AC 37 ms
9,092 KB
testcase_11 AC 45 ms
10,416 KB
testcase_12 AC 80 ms
11,280 KB
testcase_13 AC 85 ms
11,224 KB
testcase_14 AC 3 ms
9,648 KB
testcase_15 AC 85 ms
11,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	int dp[10][200020];
	for(int i=0; i<=n; i++) for(int j=0; j<10; j++) dp[j][i]=-1;
	dp[0][0]=0;
	for(int i=0; i<n; i++){
		int a; cin>>a;
		a%=10;
		for(int j=0; j<10; j++){
			if(dp[j][i]==-1) continue;
			dp[j][i+1]=max(dp[j][i+1], dp[j][i]);
			dp[(j+a)%10][i+1]=max(dp[(j+a)%10][i+1], dp[j][i]+1);
		}
	}
	cout<<dp[0][n]<<endl;
	return 0;
}

0