結果

問題 No.1708 Quality of Contest
ユーザー platinum
提出日時 2020-09-15 22:44:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 717 bytes
コンパイル時間 1,479 ms
コンパイル使用メモリ 173,588 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-09-17 16:51:48
合計ジャッジ時間 5,546 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 1 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;

int main(){
	int N, M;
	LL X;
	cin >> N >> M >> X;
	vector<LL> V(N), G(N);
	rep(i,N) cin >> V[i] >> G[i];
	int K;
	cin >> K;
	vector<int> p(K);
	rep(i,K) cin >> p[i];
	if(N >= 10){
		cout << 0 << endl;
		return 0;
	}
	vector<int> per(N);
	LL ans = 0;
	rep(i,N) per[i] = i;
	do{
		LL res = 0;
		rep(i,K){
			LL kind = 0;
			vector<bool> solved(M);
			rep(j,p[i]){
				int num = per[j];
				res += V[num];
				if(!solved[G[num]]) kind++;
				solved[G[num]] = true;
			}
			res += X * kind;
		}
		ans = max(ans,res);

	}while(next_permutation(per.begin(),per.end()));
	cout << ans << endl;

	return 0;
}
0