Submission #5607542


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

int N, M;
priority_queue<int, vector<int>, greater<int>> pq;
int arr[100005];
vector<pair<int, int>> v;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;
    for(int i = 1; i<=N; i++){
        cin >> arr[i];
        pq.push(arr[i]);
    }
    sort(arr+1, arr+1+N);
    for(int i= 1; i<=M; i++){
        pair<int ,int> p;
        cin >> p.second >> p.first;
        v.push_back(p);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int k = N;
    for(auto p : v){
        int cnt = p.second;
        while(pq.top() < p.first && cnt--){
            pq.pop();
            pq.push(p.first);
        }
    }
    long long s = 0;
    for(int i = 1; i<=N; i++){
        s += pq.top();
        pq.pop();
    }
    cout << s << endl;
}

Submission Info

Submission Time
Task D - Integer Cards
User AQT
Language C++14 (GCC 5.4.1)
Score 400
Code Size 864 Byte
Status
Exec Time 62 ms
Memory 2168 KB

Test Cases

Set Name Score / Max Score Test Cases
All 400 / 400 sample_01, sample_02, sample_03, sample_04, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_19, testcase_20
Sample 0 / 0 sample_01, sample_02, sample_03, sample_04
Case Name Status Exec Time Memory
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB
sample_04 1 ms 256 KB
testcase_01 26 ms 1020 KB
testcase_02 62 ms 2168 KB
testcase_03 37 ms 2168 KB
testcase_04 15 ms 1400 KB
testcase_05 1 ms 256 KB
testcase_06 56 ms 2168 KB
testcase_07 60 ms 2168 KB
testcase_08 24 ms 1148 KB
testcase_09 48 ms 1912 KB
testcase_10 19 ms 892 KB
testcase_11 58 ms 2168 KB
testcase_12 33 ms 1148 KB
testcase_13 48 ms 2168 KB
testcase_14 53 ms 2040 KB
testcase_15 58 ms 2168 KB
testcase_16 25 ms 1020 KB
testcase_17 50 ms 1784 KB
testcase_18 50 ms 1784 KB
testcase_19 39 ms 2168 KB
testcase_20 38 ms 2168 KB