結果

問題 No.1708 Quality of Contest
ユーザー trineutrontrineutron
提出日時 2021-10-15 21:32:47
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 974 bytes
コンパイル時間 3,102 ms
コンパイル使用メモリ 261,340 KB
実行使用メモリ 16,596 KB
最終ジャッジ日時 2023-10-17 20:04:30
合計ジャッジ時間 8,712 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 6 ms
4,348 KB
testcase_04 AC 6 ms
4,348 KB
testcase_05 AC 6 ms
4,348 KB
testcase_06 AC 5 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 245 ms
16,596 KB
testcase_10 AC 213 ms
11,132 KB
testcase_11 AC 244 ms
9,200 KB
testcase_12 AC 246 ms
10,216 KB
testcase_13 AC 234 ms
8,372 KB
testcase_14 AC 247 ms
10,796 KB
testcase_15 AC 262 ms
14,312 KB
testcase_16 AC 254 ms
13,976 KB
testcase_17 AC 238 ms
11,244 KB
testcase_18 AC 240 ms
11,536 KB
testcase_19 AC 243 ms
12,540 KB
testcase_20 AC 236 ms
11,060 KB
testcase_21 AC 249 ms
11,880 KB
testcase_22 AC 249 ms
10,872 KB
testcase_23 AC 255 ms
14,088 KB
testcase_24 AC 207 ms
6,948 KB
testcase_25 AC 204 ms
6,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> score(m);
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        b--;
        score.at(b).push_back(a);
    }
    vector<int> scores;
    for (int i = 0; i < m; i++)
    {
        if (score.at(i).empty())
        {
            continue;
        }
        sort(score.at(i).rbegin(), score.at(i).rend());
        score.at(i).at(0) += x;
        for (auto &&s : score.at(i))
        {
            scores.push_back(s);
        }
    }
    sort(scores.rbegin(), scores.rend());
    vector<int64_t> scores_sum(n + 1);
    for (int i = 0; i < n; i++)
    {
        scores_sum.at(i + 1) = scores_sum.at(i) + scores.at(i);
    }
    int64_t ans = 0;
    int k;
    cin >> k;
    for (int i = 0; i < k; i++)
    {
        int c;
        cin >> c;
        ans += scores_sum.at(c);
    }
    cout << ans << endl;
    return 0;
}
0