Submission #394975

# Submission time Handle Problem Language Result Execution time Memory
394975 2021-04-27T14:45:13 Z ak2006 Hotel (CEOI11_hot) C++14
100 / 100
2231 ms 98156 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
const ll mod = 1e9 + 7,inf = 1e18;
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,m,o;
ll out;
bool cmp2(vl&f,vl&s)
{
    return (f[0] > s[0]) or (f[0] == s[0] && f[1] < s[1]);
}
int main()
{
    cin>>n>>m>>o;
    set<vl>s;
    for (int i = 0;i<n;i++){ll x,y;cin>>x>>y;s.insert({y,x,i + 1});}
    vl profits;
    vvl offers(m,vl(2));

    for (int i = 0;i<m;i++)cin>>offers[i][0]>>offers[i][1];
    sort(offers.begin(),offers.end(),cmp2);

    for (int i = 0;i<m;i++){
        auto it = s.lower_bound({offers[i][1],0,0});
        if (it == s.end())continue;
        profits.pb(offers[i][0] - (*it)[1]);
        s.erase(it);
    }
    sort(profits.rbegin(),profits.rend());
    for (int i = 0;i<min(o,(int)profits.size());i++)if (profits[i] > 0)out += profits[i];
    cout<<out;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 137 ms 6872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 249 ms 11760 KB Output is correct
2 Correct 150 ms 9740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 726 ms 32192 KB Output is correct
2 Correct 343 ms 21772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1640 ms 64144 KB Output is correct
2 Correct 1832 ms 79552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1945 ms 78880 KB Output is correct
2 Correct 2211 ms 98156 KB Output is correct
3 Correct 2231 ms 95244 KB Output is correct