結果
問題 | No.1279 Array Battle |
ユーザー |
![]() |
提出日時 | 2020-11-06 21:33:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 578 bytes |
コンパイル時間 | 1,820 ms |
コンパイル使用メモリ | 168,964 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-22 12:19:19 |
合計ジャッジ時間 | 2,642 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>#define rep(i,n) for(int i=(0);i<(n);i++)using namespace std;typedef long long ll;int main(){cin.tie(0);ios::sync_with_stdio(false);int n;cin >> n;vector<int> a(n), b(n);rep(i, n) cin >> a[i];rep(i, n) cin >> b[i];vector<int> idx(n);rep(i, n) idx[i] = i;int ans = 0;int mx = 0;do{int tmp = 0;rep(i, n){if(a[idx[i]] > b[i]) tmp += a[idx[i]] - b[i];}if(tmp > mx){ans = 1;mx = tmp;}else if(tmp == mx){ans++;}}while(next_permutation(idx.begin(), idx.end()));cout << ans << endl;}