結果

問題 No.1279 Array Battle
ユーザー higopon_higopon_
提出日時 2020-11-06 21:54:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 1,111 bytes
コンパイル時間 1,843 ms
コンパイル使用メモリ 171,696 KB
実行使用メモリ 393,984 KB
最終ジャッジ日時 2023-09-29 18:39:49
合計ジャッジ時間 7,442 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 239 ms
393,580 KB
testcase_01 AC 240 ms
393,752 KB
testcase_02 AC 196 ms
393,984 KB
testcase_03 AC 196 ms
393,604 KB
testcase_04 AC 194 ms
393,720 KB
testcase_05 AC 194 ms
393,668 KB
testcase_06 AC 196 ms
393,664 KB
testcase_07 AC 195 ms
393,700 KB
testcase_08 AC 196 ms
393,664 KB
testcase_09 AC 196 ms
393,536 KB
testcase_10 AC 195 ms
393,852 KB
testcase_11 AC 196 ms
393,516 KB
testcase_12 AC 195 ms
393,672 KB
testcase_13 AC 195 ms
393,608 KB
testcase_14 AC 197 ms
393,672 KB
testcase_15 AC 195 ms
393,520 KB
testcase_16 AC 197 ms
393,664 KB
testcase_17 AC 200 ms
393,520 KB
testcase_18 AC 200 ms
393,464 KB
testcase_19 AC 200 ms
393,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define PI acos(-1)
typedef  long long ll;
ll MOD=1000000007;

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
int kai(int x){
   if(x!=0){
      return x*kai(x-1);  
   }
   return 1;
}
int main(){
   int n;
   cin>>n;
   vector<int> a(n);
   vector<int> b(n);
   rep(i,n){
      cin>>a[i];
   }
   rep(i,n){
      cin>>b[i];
   }
   int ma=0;
   int ans=0;
   sort(all(a));
   do{
      int tmp=0;
      int j=0;
      for(int i=0;i<n;i++){
         if(a[i]>b[j]){
            tmp+=a[i]-b[j];
         }
         j++;
      }
      if(ans==tmp){
         ma++;
      }
      if(ans<tmp){
         ma=1;
      }
      ans=max(ans,tmp);
   }while(next_permutation(all(a)));
   sort(all(a));
   // ma:場合の数
   vector<int> x(100000010,0);
   rep(i,n){
      x[a[i]]++;
   }
   int y=1;
   rep(i,x.size()){
      if(x[i]>1){
         y*=kai(x[i]);
      }
   }
   cout<<ma*y<<endl;
 
   return 0;
}
0