結果

問題 No.1708 Quality of Contest
ユーザー Example0911Example0911
提出日時 2021-10-20 18:26:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 898 bytes
コンパイル時間 2,447 ms
コンパイル使用メモリ 212,356 KB
実行使用メモリ 20,380 KB
最終ジャッジ日時 2023-10-20 11:06:38
合計ジャッジ時間 6,166 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 4 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 103 ms
20,380 KB
testcase_10 AC 86 ms
15,712 KB
testcase_11 AC 109 ms
14,008 KB
testcase_12 AC 111 ms
14,884 KB
testcase_13 AC 102 ms
13,212 KB
testcase_14 AC 115 ms
15,292 KB
testcase_15 AC 124 ms
18,356 KB
testcase_16 AC 125 ms
18,044 KB
testcase_17 AC 114 ms
15,752 KB
testcase_18 AC 104 ms
16,016 KB
testcase_19 AC 114 ms
16,912 KB
testcase_20 AC 103 ms
15,588 KB
testcase_21 AC 115 ms
16,136 KB
testcase_22 AC 111 ms
15,360 KB
testcase_23 AC 120 ms
18,148 KB
testcase_24 AC 86 ms
11,844 KB
testcase_25 AC 85 ms
11,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define int long long

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 998244353;


void solve() {
	int N, M, X; cin >> N >> M >> X;
	vector<int>A(N), B(N);
	vector<vector<int>>t(M);
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i]; B[i]--;
		t[B[i]].push_back(A[i]);
	}
	for (int i = 0; i < M; i++)sort(t[i].rbegin(), t[i].rend());
	vector<int>V;
	for (int i = 0; i < M; i++) {
		int now = 0;
		for (auto x : t[i]) {
			if (now == 0)V.push_back(x + X);
			else V.push_back(x);
			now++;
		}
	}
	sort(V.rbegin(), V.rend());
	vector<int>sum(N + 1);
	for (int i = 0; i < N; i++)sum[i + 1] = sum[i] + V[i];
	int K; cin >> K;
	int ans = 0;
	for (int i = 0; i < K; i++) {
		int C; cin >> C;
		ans += sum[C];
	}
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;

}
0