結果

問題 No.1708 Quality of Contest
ユーザー hamigakiko0721hamigakiko0721
提出日時 2022-01-30 20:24:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,173 bytes
コンパイル時間 1,741 ms
コンパイル使用メモリ 175,624 KB
実行使用メモリ 17,036 KB
最終ジャッジ日時 2023-09-02 01:48:12
合計ジャッジ時間 9,690 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 238 ms
17,036 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
using LL = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); ++i)
template<class T>void chmin(T&a, T b){if(a > b) a = b;}
template<class T>void chmax(T&a, T b){if(a < b) a = b;}


int main(){
	LL N, M, X; cin >> N >> M >> X;
	vector<vector<LL>> problem(M,vector<LL>());
	//ジャンル別に問題を整理
	for(LL i = 0; i < N; ++i){
		LL A, B; cin >> A >> B;
		--B;
		problem[B].push_back(A);
	}
	//その問題を降順に整理
	for(LL i = 0; i < M; ++i){
		sort(problem[i].rbegin(), problem[i].rend());
	}
	//優先度の高い各ジャンルの一番高い得点に+X
	for(LL i = 0; i < M; ++i) problem[i][0] += X;
	vector<LL> ALL;
	for(LL i = 0; i < M; ++i){
		for(auto v : problem[i]){
			ALL.push_back(v);
		}
	}
	sort(ALL.rbegin(), ALL.rend());
	vector<LL> S(N+1, 0);
	for(LL i = 0; i < N; ++i) S[i+1] = S[i] + ALL[i];
	LL K; cin >> K;
	LL res = 0;
	for(LL i = 0; i < K; ++i){
		LL C; cin >> C;
		res += S[C];
	}
	cout << res << endl;
}

0