結果

問題 No.1231 Make a Multiple of Ten
ユーザー motmot
提出日時 2020-09-26 02:42:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,634 bytes
コンパイル時間 613 ms
コンパイル使用メモリ 85,280 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 20:10:40
合計ジャッジ時間 2,913 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int tmp;
  int a[10];
  for(int i=0;i<10;++i) a[i] = 0;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    a[tmp%10]++;
  }
  int ans = 0;
  ans += a[0];
  a[0] = 0;
  ans += a[1]/10*10;
  a[1] %= 10;
  ans += a[2]/5*5;
  a[2] %= 5;
  ans += a[3]/10*10;
  a[3] %= 10;
  ans += a[4]/5*5;
  a[4] %= 5;
  ans += a[5]/2*2;
  a[5] %= 2;
  ans += a[6]/5*5;
  a[6] %= 5;
  ans += a[7]/10*10;
  a[7] %= 10;
  ans += a[8]/5*5;
  a[8] %= 5;
  ans += a[9]/10*10;
  a[9] %= 10;
  int ans1 = 0;
  for(int t1=0;t1<=a[1];++t1) {
    for(int t2=0;t2<=a[2];++t2) {
      for(int t3=0;t3<=a[3];++t3) {
        for(int t4=0;t4<=a[4];++t4) {
          for(int t5=0;t5<=a[5];++t5) {
            for(int t6=0;t6<=a[6];++t6) {
              for(int t7=0;t7<=a[7];++t7) {
                for(int t8=0;t8<=a[8];++t8) {
                  for(int t9=0;t9<=a[9];++t9) {
                    if((t1+2*t2+3*t3+4*t4+5*t5+6*t6+7*t7+8*t8+9*t9)%10==0) {
                      ans1 = max(ans1, t1+t2+t3+t4+t5+t6+t7+t8+t9);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout<<ans+ans1<<endl;
}

0