結果
問題 |
No.1279 Array Battle
|
ユーザー |
![]() |
提出日時 | 2020-05-19 23:59:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 829 bytes |
コンパイル時間 | 1,116 ms |
コンパイル使用メモリ | 77,364 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-15 16:30:29 |
合計ジャッジ時間 | 2,339 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cassert> #define rep(i,n) for(int i=0; i<(int)(n); i++) using namespace std; const int Max_Num=9; const int Max_Fac=1e8; int main(){ int N; cin >> N; assert(N>=1 && N<=Max_Num); vector<int> a(N), b(N); rep(i,N){ int A; cin >> A; assert(A>=1 && A<=Max_Fac); a[i]=A; } rep(i,N){ int B; cin >> B; assert(B>=1 && B<=Max_Fac); b[i]=B; } vector<int> p(N), point; rep(i,N) p[i]=i; do{ int res=0; rep(i,N) if(a[p[i]]>b[i]) res+=a[p[i]]-b[i]; point.emplace_back(res); }while (next_permutation(p.begin(),p.end())); sort(point.begin(),point.end(),greater<int>()); int MAX=point[0], ans=0; rep(i,point.size()){ if(point[i]==MAX) ans++; else break; } cout << ans << endl; return 0; }