結果

問題 No.1708 Quality of Contest
ユーザー milanis48663220milanis48663220
提出日時 2021-10-15 21:54:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 1,694 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 131,100 KB
実行使用メモリ 16,476 KB
最終ジャッジ日時 2023-10-17 20:15:58
合計ジャッジ時間 5,348 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 4 ms
4,348 KB
testcase_04 AC 4 ms
4,348 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 126 ms
16,476 KB
testcase_10 AC 125 ms
12,600 KB
testcase_11 AC 145 ms
10,104 KB
testcase_12 AC 150 ms
10,980 KB
testcase_13 AC 138 ms
9,308 KB
testcase_14 AC 156 ms
11,388 KB
testcase_15 AC 166 ms
14,452 KB
testcase_16 AC 167 ms
14,140 KB
testcase_17 AC 151 ms
11,848 KB
testcase_18 AC 153 ms
12,112 KB
testcase_19 AC 157 ms
13,008 KB
testcase_20 AC 149 ms
11,684 KB
testcase_21 AC 162 ms
12,232 KB
testcase_22 AC 158 ms
11,456 KB
testcase_23 AC 166 ms
14,244 KB
testcase_24 AC 124 ms
7,940 KB
testcase_25 AC 125 ms
7,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll n, m, x; cin >> n >> m >> x;
    vector<vector<ll>> q(m);
    for(int i = 0; i < n; i++) {
        int a, b; cin >> a >> b; b--;
        q[b].push_back(a);
    }
    priority_queue<ll> que;
    for(int i = 0; i < m; i++){
        if(q[i].empty()) continue;
        sort(q[i].begin(), q[i].end(), greater<ll>());
        q[i][0] += x;
        for(ll x: q[i]) {
            que.push(x);
        }
    }
    int k; cin >> k;
    vector<int> c(k);
    for(int i = 0; i < k; i++) cin >> c[i];
    sort(c.begin(), c.end());
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        auto p = lower_bound(c.begin(), c.end(), i);
        int j = p-c.begin();
        ll y = que.top(); que.pop();
        // debug_value(k-j);
        ans += (k-j)*y;
    }
    cout << ans << endl;
}
0