結果

問題 No.1279 Array Battle
ユーザー MTGSMTGS
提出日時 2020-11-06 21:29:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,319 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 177,508 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 18:12:14
合計ジャッジ時間 2,555 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1777777777;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

//mat G(N);
void no_cost_graphmake(ll E,mat &G){
  rep(i,E){
    ll a,b;
    cin >> a >> b;
    G.at(a-1).push_back(b-1);
    G.at(b-1).push_back(a-1);//有向なら消す
  }
}
//vec d(N);
void no_cost_dijkstra(ll s,vec &d, mat &G,ll V){
  queue<ll> que;
  rep(i,V) d.at(i)=INF;
  d.at(s)=0;
  que.push(s);
  while(!que.empty()){
    ll p=que.front();
    que.pop();
    rep(i,G.at(p).size()){
      ll e=G.at(p).at(i);
      if(d.at(e)>d.at(p)+1){
        d.at(e)=d.at(p)+1;
        que.push(e);
      }
    }
  }
}

int main(){
  ll N;
  cin >> N;
  vec A(N),B(N);
  rep(i,N) cin >> A.at(i);
  rep(i,N) cin >> B.at(i);
  ll ans=0,t=-1;
  sort(all(A));
  do{
    ll k=0;
    rep(i,N){
      k+=max(A.at(i)-B.at(i),(ll)0);
    }
    if(t==k){
      ans++;
    }else if(t<k){
      ans=1;
      t=k;
    }
  }while(next_permutation(all(A)));
  sort(all(A));
  rep(i,N-1){
    ll k=1;
    while(i<N-1&&A.at(i)==A.at(i+1)){
      i++;
      k++;
      ans*=k;
    }
  }
  cout << ans << endl;
}
0