Submission #6818067


Source Code Expand

Copy
using namespace std;
#include <iostream>
#include<bits/stdc++.h>
#define pb push_back
#define MAX 300
#define pi 3.1415926536
#define ip pair<int,int>
#define mp make_pair
#define ss second
#define ff first
#define ull unsigned long long
#define ll long long
#define MOD 1000000000
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fn(i,n) for (ll i=0; i<n; i++)
#define endl "\n"
#define Endl endl
#define int long long
#define EN cout<<endl;
#define inp(n) int n; cin>>n;
#define TEST int t; cin>>t; while(t--)
ll power(ll x, ll y, ll p) { int res = 1; x = x % p;  while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;} return res; } 
ll PO(ll a, ll n) { ll val=1; fn(i,n) val*=a; return val;  }
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second < b.second); }
 
signed main ()
{
    int n,m; cin>>n>>m;
    int f[100006]={0};
    ll cnt=0;
    priority_queue <int> g;
    vector<int> v[100005];
    for (int i=0; i<n; i++)
    {
        inp(x); inp(y);
        v[x].pb(y);
    }

    for (int i=1; i<=m; i++)
    {
        if (v[i].size()>0)
        {
            for (int j=0; j<v[i].size(); j++)
                g.push(v[i][j]);
        }
        if (!g.empty())
        {
            cnt+=g.top();
            g.pop();
        }
    }
    cout<<cnt;
}

Submission Info

Submission Time
Task D - Summer Vacation
User sarthakk_26
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1383 Byte
Status AC
Exec Time 68 ms
Memory 5632 KB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 21
AC × 3
Set Name Test Cases
All 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 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 AC 2 ms 2560 KB
sample_02 AC 2 ms 2560 KB
sample_03 AC 2 ms 2560 KB
testcase_01 AC 11 ms 2944 KB
testcase_02 AC 4 ms 2688 KB
testcase_03 AC 51 ms 4352 KB
testcase_04 AC 68 ms 4736 KB
testcase_05 AC 68 ms 4736 KB
testcase_06 AC 60 ms 4480 KB
testcase_07 AC 63 ms 5632 KB
testcase_08 AC 18 ms 3360 KB
testcase_09 AC 37 ms 4344 KB
testcase_10 AC 55 ms 4856 KB
testcase_11 AC 56 ms 4720 KB
testcase_12 AC 17 ms 3216 KB
testcase_13 AC 61 ms 4592 KB
testcase_14 AC 52 ms 4596 KB
testcase_15 AC 6 ms 2816 KB
testcase_16 AC 58 ms 4580 KB
testcase_17 AC 10 ms 3072 KB
testcase_18 AC 55 ms 5116 KB