이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, o;
cin >> n >> m >> o;
multiset<pll> rooms; //(capacity, upkeep)
for(int i = 1; i <= n; i++)
{
ll c, p;
cin >> c >> p;
rooms.insert({p, c});
}
vector<pll> offers(m); //(capacity requirement, gain)
for(int j = 0; j < m; j++)
{
cin >> offers[j].second >> offers[j].first;
}
sort(offers.begin(), offers.end(), [] (pll U, pll V)
{
return U.second > V.second;
});
ll res = 0;
int accepted = 0;
for(pll z : offers)
{
if(accepted == o) break;
ll capreq = z.first;
ll gain = z.second;
auto f = rooms.lower_bound({capreq, -1});
if(f == rooms.end()) continue;
if(f->second >= gain) continue;
res += gain - f->second;
accepted++;
rooms.erase(f);
}
cout << res << '\n';
}
# | 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... |
# | 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... |