結果
| 問題 |
No.1231 Make a Multiple of Ten
|
| コンテスト | |
| ユーザー |
Inazuma_110
|
| 提出日時 | 2020-09-18 22:36:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,579 bytes |
| コンパイル時間 | 6,666 ms |
| コンパイル使用メモリ | 383,424 KB |
| 最終ジャッジ日時 | 2025-01-14 17:34:39 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 WA * 12 |
ソースコード
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>
using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;
#if __has_include("print.hpp")
#include "print.hpp"
#endif
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll, ll> p;
vector<vector<int>> table2;
void f(vector<int> table, int sum, int b){
if(sum == 10){
table2.push_back(table);
return;
}
for (int i = b; i < 10; ++i) {
auto tmp = table;
tmp.push_back(i);
if(sum + i <= 10) f(tmp, sum + i, i);
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> v(n);
vector<int> d(10);
rep(i, n){
cin >> v[i];
v[i] %= 10;
d[v[i]]++;
}
ll res = d[0];
f(vector<int>(), 0, 1);
sort(ALL(table2), [](auto const& a, auto const& b){return a.size() > b.size();});
for(auto table : table2){
vector<int> tmp(10);
for(auto val : table){
tmp[val]++;
}
int cnt = INT_MAX;
for (int i = 1; i < 10; ++i) {
if(tmp[i] >= 1){
chmin(cnt, d[i] / tmp[i]);
}
}
res += cnt * int(table.size());
for (int i = 1; i < 10; ++i) {
d[i] -= cnt * tmp[i];
}
}
cout << res << endl;
}
Inazuma_110