結果

問題 No.1708 Quality of Contest
ユーザー se1ka2se1ka2
提出日時 2021-10-15 21:51:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 1,083 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 80,836 KB
実行使用メモリ 9,036 KB
最終ジャッジ日時 2023-10-17 20:14:46
合計ジャッジ時間 5,739 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,740 KB
testcase_01 AC 4 ms
7,740 KB
testcase_02 AC 4 ms
7,740 KB
testcase_03 AC 8 ms
7,740 KB
testcase_04 AC 7 ms
7,744 KB
testcase_05 AC 7 ms
7,744 KB
testcase_06 AC 7 ms
7,744 KB
testcase_07 AC 7 ms
7,740 KB
testcase_08 AC 4 ms
7,740 KB
testcase_09 AC 219 ms
7,740 KB
testcase_10 AC 206 ms
9,036 KB
testcase_11 AC 205 ms
8,208 KB
testcase_12 AC 207 ms
8,244 KB
testcase_13 AC 205 ms
8,772 KB
testcase_14 AC 207 ms
8,244 KB
testcase_15 AC 209 ms
7,740 KB
testcase_16 AC 209 ms
8,128 KB
testcase_17 AC 203 ms
8,244 KB
testcase_18 AC 205 ms
8,244 KB
testcase_19 AC 204 ms
8,128 KB
testcase_20 AC 203 ms
8,568 KB
testcase_21 AC 207 ms
7,740 KB
testcase_22 AC 207 ms
7,740 KB
testcase_23 AC 211 ms
7,740 KB
testcase_24 AC 200 ms
9,036 KB
testcase_25 AC 199 ms
9,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

int main()
{
    int n, m;
    ll x;
    cin >> n >> m >> x;
    P p[200005];
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        p[i] = P(a, b);
    }
    sort(p, p + n, greater<P>());
    int k;
    cin >> k;
    int d[200005]{0};
    for(int i = 0; i < k; i++){
        int c;
        cin >> c;
        d[c]++;
    }
    int j = 0;
    int c = k;
    ll ans = 0;
    queue<ll> que;
    bool b[200005]{0};
    for(int i = 0; i < n; i++){
        if(!b[p[i].second]){
            b[p[i].second] = true;
            while(!que.empty() && que.front() >= p[i].first + x){
                c -= d[j++];
                ans += que.front() * c;
                que.pop();
            }
            c -= d[j++];
            ans += (p[i].first + x) * c;
        }
        else que.push(p[i].first);
    }
    while(!que.empty()){
        c -= d[j++];
        ans += que.front() * c;
        que.pop();
    }
    cout << ans << endl;
}
0