This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define pll pair<lli,lli>
//para el vector de orden
#define w first
#define d second
lli a,b,res,cant,n,k;
vector<pll> orden;
set<lli> dispo;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
rep(i,1,n) {
cin >> a >> b;
orden.push_back({a,b});
}
sort(orden.begin(), orden.end());
repa(i,n,1) dispo.emplace_hint(dispo.end(), -i);
res = 0;
cant = 0;
for (auto act : orden) {
auto it = dispo.lower_bound(-act.d);
if (it == dispo.end()) continue;
cant++;
res += act.w;
dispo.erase(it);
}
cout << cant << ' ' << res;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |