結果
| 問題 | No.1279 Array Battle | 
| コンテスト | |
| ユーザー |  Nachia | 
| 提出日時 | 2020-11-06 22:22:54 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 7 ms / 2,000 ms | 
| コード長 | 635 bytes | 
| コンパイル時間 | 1,814 ms | 
| コンパイル使用メモリ | 169,744 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-22 13:07:11 | 
| 合計ジャッジ時間 | 2,267 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int N;
int A[9];
int B[9];
int main() {
	int N; cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	vector<int> P(N); rep(i, N) P[i] = i;
	int maxscore = 0, maxscoreC = 0;
	do {
		int score = 0;
		rep(i, N) {
			if (A[P[i]] > B[i]) score += A[P[i]] - B[i];
		}
		if (maxscore < score) { maxscore = score; maxscoreC = 1; }
		else if (maxscore == score) { maxscore = score; maxscoreC += 1; }
	}
	while (next_permutation(P.begin(), P.end()));
	cout << maxscoreC << endl;
	return 0;
}
            
            
            
        