結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 36 ms
4,376 KB
testcase_05 AC 47 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 55 ms
4,380 KB
testcase_08 AC 13 ms
4,376 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 35 ms
4,376 KB
testcase_11 AC 44 ms
4,380 KB
testcase_12 AC 71 ms
4,376 KB
testcase_13 AC 77 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 73 ms
4,380 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]/10*10;
  a[2] %= 10;
  ans += a[3]/10*10;
  a[3] %= 10;
  ans += a[4]/10*10;
  a[4] %= 10;
  ans += a[5]/10*10;
  a[5] %= 10;
  ans += a[6]/10*10;
  a[6] %= 10;
  ans += a[7]/10*10;
  a[7] %= 10;
  ans += a[8]/10*10;
  a[8] %= 10;
  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