結果
| 問題 |
No.1279 Array Battle
|
| コンテスト | |
| ユーザー |
MTGS
|
| 提出日時 | 2020-11-06 21:28:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 1,367 bytes |
| コンパイル時間 | 3,557 ms |
| コンパイル使用メモリ | 236,620 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 12:12:23 |
| 合計ジャッジ時間 | 4,194 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#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;
}
MTGS