結果

問題 No.1708 Quality of Contest
ユーザー atjh16atjh16
提出日時 2021-10-17 11:58:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 4,076 ms
コンパイル使用メモリ 210,048 KB
実行使用メモリ 18,948 KB
最終ジャッジ日時 2023-10-17 22:26:26
合計ジャッジ時間 8,299 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
8,324 KB
testcase_01 AC 4 ms
8,324 KB
testcase_02 AC 4 ms
8,328 KB
testcase_03 AC 7 ms
8,496 KB
testcase_04 AC 8 ms
8,516 KB
testcase_05 AC 7 ms
8,484 KB
testcase_06 AC 6 ms
8,460 KB
testcase_07 AC 6 ms
8,464 KB
testcase_08 AC 4 ms
8,276 KB
testcase_09 AC 248 ms
18,948 KB
testcase_10 AC 215 ms
14,264 KB
testcase_11 AC 246 ms
15,916 KB
testcase_12 AC 247 ms
16,132 KB
testcase_13 AC 241 ms
15,656 KB
testcase_14 AC 253 ms
16,196 KB
testcase_15 AC 257 ms
16,924 KB
testcase_16 AC 256 ms
16,852 KB
testcase_17 AC 242 ms
16,328 KB
testcase_18 AC 245 ms
16,416 KB
testcase_19 AC 246 ms
16,732 KB
testcase_20 AC 241 ms
16,268 KB
testcase_21 AC 255 ms
16,380 KB
testcase_22 AC 250 ms
16,220 KB
testcase_23 AC 256 ms
16,876 KB
testcase_24 AC 212 ms
15,048 KB
testcase_25 AC 213 ms
15,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long n, k, m, x, c, s, t, z = 0;
vector<long long> a[200000];
vector<long long> b, d;

int main()
{
	cin >> n >> m >> x;

	for (int i = 0; i < n; i++) {
		cin >> s >> t;
		t--;

		a[t].push_back(s);
	}

	for (int i = 0; i < m; i++) {
		if (a[i].size() > 0) {
			sort(a[i].begin(), a[i].end());
			a[i].back() += x;

			for (long long j : a[i])
				b.push_back(j);
		}
	}

	sort(b.begin(), b.end(), greater<long long>());
	d.push_back(b[0]);

	for (int i = 1; i < b.size(); i++)
		d.push_back(d.back() + b[i]);

	cin >> k;

	for (int i = 0; i < k; i++) {
		cin >> c;

		if(c > 0)
			z += d[c - 1];
	}

	cout << z << endl;
}
0