結果

問題 No.1708 Quality of Contest
ユーザー forest3forest3
提出日時 2021-11-13 18:07:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 1,885 ms
コンパイル使用メモリ 179,652 KB
実行使用メモリ 18,200 KB
最終ジャッジ日時 2024-05-05 17:09:03
合計ジャッジ時間 8,167 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 209 ms
18,200 KB
testcase_10 AC 190 ms
12,736 KB
testcase_11 AC 209 ms
10,732 KB
testcase_12 AC 218 ms
11,816 KB
testcase_13 AC 203 ms
9,976 KB
testcase_14 AC 206 ms
12,404 KB
testcase_15 AC 226 ms
15,788 KB
testcase_16 AC 222 ms
15,456 KB
testcase_17 AC 208 ms
12,716 KB
testcase_18 AC 202 ms
13,136 KB
testcase_19 AC 206 ms
14,140 KB
testcase_20 AC 202 ms
12,664 KB
testcase_21 AC 213 ms
13,480 KB
testcase_22 AC 207 ms
12,476 KB
testcase_23 AC 216 ms
15,692 KB
testcase_24 AC 184 ms
8,428 KB
testcase_25 AC 193 ms
8,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N, M;
	long long X;
	cin >> N >> M >> X;
	vector<vector<int>> g( M );
	for( int i = 0; i < N; i++ ) {
		int A, B;
		cin >> A >> B;
		B--;
		g[B].push_back( A );
	}
	int K;
	cin >> K;
	vector<int> C( K );
	for( int i = 0; i < K; i++ ) cin >> C[i];

	for( int i = 0; i < M; i++ ) {
		if( g[i].size() == 0 ) continue;
		sort( g[i].begin(), g[i].end(), greater<int>() );
	}
	vector<long long> v;
	for( int i = 0; i < M; i++ ) {
		int n = g[i].size();
		if( n == 0 ) continue;
		for( int j = 0; j < n; j++ ) {
			long long a = g[i][j];
			if( j == 0 ) a += X;
			v.push_back( a );
		}
	}
	sort( v.begin(), v.end(), greater<long long>() );
	vector<long long> acc( N + 1 );
	for( int i = 0; i < N; i++ ) acc[i + 1] = acc[i] + v[i];
	long long ans = 0;
	for( int i = 0; i < K; i++ ) {
		ans += acc[ C[i] ];
	}

	cout << ans << endl;
}
0