結果

問題 No.1708 Quality of Contest
ユーザー たこしたこし
提出日時 2021-10-15 22:08:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 269 ms / 2,000 ms
コード長 1,781 bytes
コンパイル時間 2,191 ms
コンパイル使用メモリ 210,776 KB
実行使用メモリ 22,540 KB
最終ジャッジ日時 2023-10-17 20:20:40
合計ジャッジ時間 7,948 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
11,792 KB
testcase_01 AC 4 ms
11,792 KB
testcase_02 AC 4 ms
11,796 KB
testcase_03 AC 7 ms
11,988 KB
testcase_04 AC 8 ms
12,032 KB
testcase_05 AC 8 ms
11,984 KB
testcase_06 AC 7 ms
11,956 KB
testcase_07 AC 7 ms
11,952 KB
testcase_08 AC 3 ms
11,792 KB
testcase_09 AC 244 ms
22,540 KB
testcase_10 AC 222 ms
18,808 KB
testcase_11 AC 247 ms
19,508 KB
testcase_12 AC 248 ms
19,724 KB
testcase_13 AC 245 ms
19,248 KB
testcase_14 AC 259 ms
19,788 KB
testcase_15 AC 266 ms
20,516 KB
testcase_16 AC 269 ms
20,444 KB
testcase_17 AC 251 ms
19,920 KB
testcase_18 AC 252 ms
20,008 KB
testcase_19 AC 255 ms
20,324 KB
testcase_20 AC 251 ms
19,860 KB
testcase_21 AC 262 ms
19,972 KB
testcase_22 AC 256 ms
19,812 KB
testcase_23 AC 266 ms
20,468 KB
testcase_24 AC 221 ms
18,640 KB
testcase_25 AC 222 ms
18,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;
const int MAX_M = 200005;
const int MAX_K = 200005;

int N, M, X;
int A[MAX_N], B[MAX_N];
vector<int> BB[MAX_M];
int K;
int C[MAX_K];

signed main() {
    cin >> N >> M >> X;
    REP(n, N) {
        cin >> A[n] >> B[n]; B[n]--;
        BB[B[n]].emplace_back(A[n]);
    }

    cin >> K;
    REP(k, K) {
        cin >> C[k];
    }

    sort(C, C+K);

    vector<int> S;
    vector<int> sumS(N+1);
    REP(m, M) {
        sort(begin(BB[m]), end(BB[m]), greater<int>());
        REP(i, BB[m].size()) {
            if (i == 0) {
                S.emplace_back(X + BB[m][i]);
            } else {
                S.emplace_back(BB[m][i]);
            }
        }
    }

    sort(begin(S), end(S), greater<int>());
    REP(n, N) {
        sumS[n+1] = sumS[n] + S[n];
    }

    int ans = 0;
    REP(k, K) {
        ans += sumS[C[k]];
    }
    cout << ans << endl;

    return 0;
}
0