Submission #6820822


Source Code Expand

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

using namespace std;

int N, M;
pair<int, int> arr[100005];
set<int> st;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> M;
    st.insert(-1);
    for(int i = 0; i<M; i++){
        st.insert(i);
    }
    for(int i = 1; i<=N; i++){
        cin >> arr[i].second >> arr[i].first;
    }
    sort(arr+1, arr+1+N, greater<pair<int, int>>());
    long long ans = 0;
    for(int i = 1; i<=N; i++){
        int k = M-arr[i].second;
        int p = *(--st.upper_bound(k));
        if(p != -1){
            ans += arr[i].first;
            st.erase(p);
        }
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task D - Summer Vacation
User AQT
Language C++14 (GCC 5.4.1)
Score 0
Code Size 686 Byte
Status
Exec Time 88 ms
Memory 5760 KB

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 400 sample_01, sample_02, sample_03, 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
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB
testcase_01 21 ms 3200 KB
testcase_02 9 ms 1920 KB
testcase_03 32 ms 2304 KB
testcase_04 88 ms 5760 KB
testcase_05 87 ms 5760 KB
testcase_06 54 ms 2816 KB
testcase_07 86 ms 5632 KB
testcase_08 14 ms 1920 KB
testcase_09 33 ms 3968 KB
testcase_10 54 ms 5760 KB
testcase_11 48 ms 5120 KB
testcase_12 12 ms 1664 KB
testcase_13 53 ms 5760 KB
testcase_14 47 ms 5376 KB
testcase_15 4 ms 640 KB
testcase_16 55 ms 5760 KB
testcase_17 8 ms 1152 KB
testcase_18 55 ms 5760 KB