結果
問題 |
No.1279 Array Battle
|
ユーザー |
![]() |
提出日時 | 2022-02-19 20:59:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 896 bytes |
コンパイル時間 | 1,438 ms |
コンパイル使用メモリ | 172,576 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-29 10:40:00 |
合計ジャッジ時間 | 2,246 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(LL i = a;i<b; i++) #define rrep(i,a,b) for(LL i = a;i>b; i--) #define tobirep(i,a,b,c) for(LL i = a;i<b; i+=c) #define tobirrep(i,a,b,c) for(LL i = a;i>b; i-=c) #define INF ((1LL<<62)-(1LL<<31)) #define ooki 9223372036854775807 #define tii -9223372036854775808 typedef long long LL; int main(){ LL n,sum=0; cin >> n; vector<LL> a(n); vector<LL> b(n); vector<LL> vec(n); rep(i,0,n){cin >> a[i];vec[i]=i;} rep(i,0,n){cin >> b[i];} sort(a.begin(),a.end()); sort(b.begin(),b.end()); reverse(a.begin(),a.end()); rep(i,0,n){ if(a[i]>=b[i]){sum+=a[i]-b[i];} } LL count = 0; do{ LL sum2 = 0; rep(i,0,n){ if(a[i]>=b[vec[i]]){sum2+=a[i]-b[vec[i]];} } if(sum2==sum){count++;} } while(next_permutation(vec.begin(),vec.end())); cout << count << endl; }