結果
| 問題 |
No.1231 Make a Multiple of Ten
|
| コンテスト | |
| ユーザー |
Im_Gimlet
|
| 提出日時 | 2020-10-05 11:33:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 117 ms / 2,000 ms |
| コード長 | 858 bytes |
| コンパイル時間 | 1,616 ms |
| コンパイル使用メモリ | 172,156 KB |
| 実行使用メモリ | 25,060 KB |
| 最終ジャッジ日時 | 2024-07-19 19:37:47 |
| 合計ジャッジ時間 | 3,188 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }
int main() {
int n; cin >> n;
vector<ll> avec(n, 0);
for(int i = 0; i < n; ++i) cin >> avec[i];
vector< vector<int> > dp(n+1, vector<int>(15, 0));
for(int i = 0; i < n; ++i) {
chmax(dp[i+1][avec[i]%10], 1);
for(int j = 0; j < 10; ++j) {
if(dp[i][j] > 0) chmax(dp[i+1][(j+avec[i])%10], dp[i][j]+1);
chmax(dp[i+1][j], dp[i][j]);
}
}
cout << dp[n][0] << endl;
}
Im_Gimlet