結果

問題 No.1231 Make a Multiple of Ten
ユーザー aajisakaaajisaka
提出日時 2020-09-23 23:56:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,477 bytes
コンパイル時間 2,194 ms
コンパイル使用メモリ 201,260 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 13:13:21
合計ジャッジ時間 5,649 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 185 ms
4,380 KB
testcase_08 AC 458 ms
4,376 KB
testcase_09 AC 123 ms
4,380 KB
testcase_10 AC 272 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 104 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 379 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 * 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;
}
0