結果
問題 | No.1231 Make a Multiple of Ten |
ユーザー | ysystem7 |
提出日時 | 2020-10-03 17:43:42 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 1,537 bytes |
コンパイル時間 | 3,330 ms |
コンパイル使用メモリ | 211,312 KB |
実行使用メモリ | 23,536 KB |
最終ジャッジ日時 | 2023-09-25 05:32:03 |
合計ジャッジ時間 | 3,642 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 28 ms
12,292 KB |
testcase_05 | AC | 24 ms
11,244 KB |
testcase_06 | AC | 11 ms
6,324 KB |
testcase_07 | AC | 29 ms
12,916 KB |
testcase_08 | AC | 14 ms
8,720 KB |
testcase_09 | AC | 7 ms
5,120 KB |
testcase_10 | AC | 26 ms
11,660 KB |
testcase_11 | AC | 30 ms
13,464 KB |
testcase_12 | AC | 54 ms
22,352 KB |
testcase_13 | AC | 57 ms
23,536 KB |
testcase_14 | AC | 2 ms
4,376 KB |
testcase_15 | AC | 56 ms
23,472 KB |
ソースコード
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i]; #define ft first #define sc second #define pb push_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(),(v).end() #define LB(a,x) lb(all(a),x)-a.begin() #define UB(a,x) ub(all(a),x)-a.begin() #define mod 1000000007 //#define mod 998244353 #define FS fixed<<setprecision(15) using namespace std; typedef long long ll; const double pi=3.141592653589793; template<class T> using V=vector<T>; using Graph = vector<vector<int>>; using P=pair<ll,ll>; typedef unsigned long long ull; typedef long double ldouble; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline void out(T a){ cout << a << '\n'; } void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;} //void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;} const ll INF=1e18; const int mx=200005; ll dp[mx][12]; int main(){ cin.tie(0);ios::sync_with_stdio(false); ll n; cin>>n; V<ll> a(n); rep(i,n){ cin>>a[i]; a[i]%=10; } dp[1][a[0]]=1; for(int i=1;i<n;i++){ for(int j=0;j<10;j++){ chmax(dp[i+1][j],dp[i][j]); if((j==0&&dp[i][j]==0)||dp[i][j]>0)chmax(dp[i+1][(j+a[i])%10],dp[i][j]+1); } } out(dp[n][0]); }