結果
| 問題 |
No.1231 Make a Multiple of Ten
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2020-09-18 21:34:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 852 bytes |
| コンパイル時間 | 735 ms |
| コンパイル使用メモリ | 83,392 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 13:39:25 |
| 合計ジャッジ時間 | 1,742 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int cnt[10];
int dp[10][10];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int N; cin >> N;
for(int i = 0; i < N; i++) {
int a; cin >> a;
cnt[a%10]++;
}
const int INF = 1e8;
dp[0][0] = cnt[0];
for(int i = 1; i <= 9; i++) dp[0][i] = -INF;
for(int i = 1; i <= 9; i++){
for(int j = 0; j <= 9; j++){
dp[i][j] = -INF;
}
for(int j = 0; j <= cnt[i]; j++){
for(int k = 0; k <= 9; k++){
int nx = (k+i*j)%10;
dp[i][nx] = max(dp[i][nx], dp[i-1][k]+j);
}
}
}
cout << dp[9][0] << endl;
}
milanis48663220