結果
| 問題 |
No.1231 Make a Multiple of Ten
|
| コンテスト | |
| ユーザー |
aajisaka
|
| 提出日時 | 2020-09-23 23:56:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,477 bytes |
| コンパイル時間 | 1,746 ms |
| コンパイル使用メモリ | 197,448 KB |
| 最終ジャッジ日時 | 2025-01-14 19:54:02 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 5 |
ソースコード
/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author aajisaka
*/
#include<bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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 ull = unsigned long long;
using P = pair<ll, ll>;
constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
class No1231MakeAMultipleOfTen {
public:
void solve(istream& cin, ostream& cout) {
SPEED;
int n; cin >> n;
vector<int> cnt(10);
rep(i, n) {
int a; cin >> a;
cnt[a%10]++;
}
int ret = cnt[0];
for(int two=max(cnt[2]-4, 0); two<=cnt[2]; two++) {
for(int three=max(cnt[3]-9, 0); three<=cnt[3]; three++) {
for(int four=max(cnt[4]-4, 0); four<=cnt[4]; four++) {
for(int five=max(cnt[5]-1, 0); five<=cnt[5]; five++) {
for(int six=max(cnt[6]-4, 0); six<=cnt[6]; six++) {
for(int seven=max(cnt[7]-9, 0); seven<=cnt[7]; seven++) {
for(int eight=max(cnt[8]-4, 0); eight<=cnt[8]; eight++) {
for(int nine=max(cnt[9]-9, 0); nine<=cnt[9]; nine++) {
for(int one=max(cnt[0]-9, 0); one<=cnt[1]; one++) {
ll now = one+two*2+three*3+four*4+five*5+six*6+seven*7+eight*8+nine*9;
if (now%10==0) {
chmax(ret, cnt[0]+one+two+three+four+five+six+seven+eight+nine);
}
}
}
}
}
}
}
}
}
}
cout << ret << endl;
}
};
signed main() {
No1231MakeAMultipleOfTen solver;
std::istream& in(std::cin);
std::ostream& out(std::cout);
solver.solve(in, out);
return 0;
}
aajisaka