Submission #6813115


Source Code Expand

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

const int MAX_N = 100000;
int n,m;
pli ab[MAX_N];

int main()
{
  cin >> n >> m;

  forn(i,n) {
    cin >> ab[i].snd >> ab[i].fst;
  }

  sort(ab,ab+n,greater<pli>());

  set<int> d;
  forn1(i,m) d.insert(i);

  ll res = 0;
  forn(i,n) {
    auto it = d.lower_bound(ab[i].snd);
    if (it != d.end()) {
      d.erase(it);
      res += ab[i].fst;
    }
  }

  cout << res << endl;

  return 0;
}

Submission Info

Submission Time
Task D - Summer Vacation
User sash0
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1325 Byte
Status AC
Exec Time 113 ms
Memory 6528 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 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 1 ms 256 KB
testcase_01 AC 24 ms 3328 KB
testcase_02 AC 9 ms 1920 KB
testcase_03 AC 58 ms 2944 KB
testcase_04 AC 111 ms 6528 KB
testcase_05 AC 113 ms 6528 KB
testcase_06 AC 77 ms 3584 KB
testcase_07 AC 110 ms 6400 KB
testcase_08 AC 21 ms 2176 KB
testcase_09 AC 48 ms 4480 KB
testcase_10 AC 77 ms 6528 KB
testcase_11 AC 78 ms 5888 KB
testcase_12 AC 20 ms 1792 KB
testcase_13 AC 89 ms 6528 KB
testcase_14 AC 81 ms 6016 KB
testcase_15 AC 6 ms 768 KB
testcase_16 AC 88 ms 6528 KB
testcase_17 AC 11 ms 1152 KB
testcase_18 AC 78 ms 6528 KB