結果
問題 |
No.1279 Array Battle
|
ユーザー |
|
提出日時 | 2020-11-12 17:44:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 612 bytes |
コンパイル時間 | 3,775 ms |
コンパイル使用メモリ | 232,816 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-22 19:39:41 |
合計ジャッジ時間 | 4,763 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; #define rep(i,n) for (int i=0; i<(n); i++) using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; int main(){ int n; cin >> n; vi a(n), b(n), c(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> b[i]; rep(i,n) c[i]=i; sort(a.begin(), a.end()); int ans=0, mx=-1; do{ int sum=0; rep(i,n) sum+=max(0, a[c[i]]-b[i]); if(sum > mx){ mx=sum; ans=0; } if(sum==mx) ans++; }while(next_permutation(c.begin(), c.end())); cout << ans << endl; }