結果

問題 No.1279 Array Battle
ユーザー onsen_manjuuu
提出日時 2020-11-06 21:24:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 1,735 ms
コンパイル使用メモリ 181,944 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-22 12:02:47
合計ジャッジ時間 2,513 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;


int main()
{
	int N; cin >> N;
	vector<pair<int,int>> A(N);
	for(int i = 0; i < N; i++)A[i].second = i;
	vector<int> B(N);
	for(int i = 0; i < N; i++)cin >> A[i].first;
	for(int i = 0; i < N; i++)cin >> B[i];
	sort(A.begin(), A.end());
	map<int,int> mp;

	do {
		int cost = 0;
		for(int i = 0; i < N; i++) cost += max(0, A[i].first - B[i]);
		mp[cost]++;
	} while (next_permutation(A.begin(), A.end()));

	cout << mp.rbegin() -> second << endl;

}
0