結果

問題 No.1231 Make a Multiple of Ten
ユーザー A0ikun_1818A0ikun_1818
提出日時 2020-09-30 23:55:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,978 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 84,540 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 19:54:23
合計ジャッジ時間 2,223 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 37 ms
4,380 KB
testcase_05 AC 33 ms
4,376 KB
testcase_06 AC 14 ms
4,380 KB
testcase_07 AC 39 ms
4,376 KB
testcase_08 AC 14 ms
4,376 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 34 ms
4,376 KB
testcase_11 AC 41 ms
4,380 KB
testcase_12 AC 75 ms
4,380 KB
testcase_13 AC 79 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 79 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define LIMIT3 1000010
#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
template<class T,class C> T max(T a,C b){ return ((a)>(T)(b) ? (a) : (T)(b)); }
template<class T,class C> T min(T a,C b){ return ((a)<(T)(b) ? (a) : (T)(b)); }
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int a[LIMIT2]={0};
int dp[30]={0};
int main(void){
  initialize();
  int n,m,i,j,k,result=0;
  string s;
  
  cin >> n;
  rep(i,n) cin >> a[i];
  
  dp[0]=0;
  for(i=1;i<20;i++) dp[i]=-9999999;
  rep(i,n){
    per(j,10){
      //cout << i <<" "<<j <<" "<<dp[j]<< endl;
      dp[(j+a[i]%10)] = max(dp[(j+a[i]%10)], dp[j]+1);
    }
    for(j=10;j<20;j++){
      dp[j%10] = max(dp[j%10],dp[j]);
      dp[j] = -9999999;
    }
  }
  result = dp[0];
  
  cout << result << endl;
  return 0;
}
0