Submission #6832972


Source Code Expand

Copy
    #include <bits/stdc++.h>
    #define hell                         1000000007 
    #define M                            1000000007
    #define Maxi                      10000000000000000
        #define lcm(a,b)                     (a*b)/__gcd(a,b)
        #define ll                           long long

        #define vll                          vector<ll>
        #define vi                           vector<long long>
        #define pll                          vector< pair<ll,ll> >
        #define pb                           push_back
        //#define mp                           make_pair
        #define all(v)                       v.begin(),v.end()
        #define lbnd                         lower_bound
        #define ubnd                         upper_bound
        #define bs                           binary_search
        #define F                            first
        #define S                            second
        #define rep(i,a,b)                   for(i=a;i<b;i++)
        #define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
        #define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
        #define ret(x)                       return cout<<x,0;
        #define dbg(x)                       cout << #x << " is " << x << endl;
        //#define endl                           '\n'
     
     
        // Debug //
     
        #define trace(x)                 cerr << #x << ": " << x << endl;
        #define trace1(x)                cerr << #x << ": " << x << endl;
        #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
        #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
        #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
        #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
        #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


    using namespace std;
  
    int main()
    {

          ios_base::sync_with_stdio(false);
          cin.tie(NULL);cout.tie(NULL);
        
          ll n,m;
          cin>>n>>m;

          //ll ans=0;

          ll i,j;
          vector<ll>v[200040];
          for(i=0;i<n;i++)
          {
            ll a,b;
            cin>>a>>b;
            v[a].pb(b);
          }

          //sort(all(v));
          priority_queue<ll>pq;
          for(i=1;i<=m;i++)
          {
            if(v[i].size())
            {
              for(auto j:v[i])
              {
                pq.push(j);
              }
              break;
            }
          }
          ll ans;
          ans=0;
          if(pq.size()>0)
          {
          ans=pq.top();
          pq.pop();
        }
          for(j=i+1;j<=m;j++)
          {
            for(auto i:v[j])
            {
              pq.push(i);
            }
            if(pq.size()>0)
            {
              ans+=pq.top();
              pq.pop();
            }
          }
          cout<<ans<<endl;
          
          
  
  return 0;
}


          

  

Submission Info

Submission Time
Task D - Summer Vacation
User prasadpichku
Language C++14 (GCC 5.4.1)
Score 400
Code Size 3564 Byte
Status AC
Exec Time 30 ms
Memory 8064 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 3 ms 4992 KB
sample_02 AC 3 ms 4992 KB
sample_03 AC 3 ms 4992 KB
testcase_01 AC 6 ms 5376 KB
testcase_02 AC 3 ms 4992 KB
testcase_03 AC 21 ms 6784 KB
testcase_04 AC 30 ms 7040 KB
testcase_05 AC 30 ms 7040 KB
testcase_06 AC 24 ms 6784 KB
testcase_07 AC 27 ms 8064 KB
testcase_08 AC 10 ms 5664 KB
testcase_09 AC 20 ms 6776 KB
testcase_10 AC 28 ms 7160 KB
testcase_11 AC 23 ms 7024 KB
testcase_12 AC 9 ms 5632 KB
testcase_13 AC 26 ms 7024 KB
testcase_14 AC 19 ms 7028 KB
testcase_15 AC 4 ms 5120 KB
testcase_16 AC 21 ms 6884 KB
testcase_17 AC 7 ms 5376 KB
testcase_18 AC 29 ms 7288 KB