結果
| 問題 |
No.1279 Array Battle
|
| コンテスト | |
| ユーザー |
yamake
|
| 提出日時 | 2020-11-06 21:55:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 1,068 bytes |
| コンパイル時間 | 1,050 ms |
| コンパイル使用メモリ | 90,784 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 12:44:11 |
| 合計ジャッジ時間 | 2,144 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
int n;cin>>n;
vector<int> b(n);
vector<P> a(n);
rep(i,n){
cin>>a[i].first;
a[i].second=i;
}
rep(i,n)cin>>b[i];
sort(a.begin(),a.end());
lint mx=0;
do{
lint buf=0;
rep(i,n){
if(a[i].first>b[i])buf+=a[i].first-b[i];
}
mx=max(mx,buf);
}while(next_permutation(a.begin(),a.end()));
int cnt=0;
sort(a.begin(),a.end());
do{
lint buf=0;
rep(i,n){
if(a[i].first>b[i])buf+=a[i].first-b[i];
}
if(buf==mx)++cnt;
}while(next_permutation(a.begin(),a.end()));
cout<<cnt<<"\n";
return 0;
}
yamake