Submission #484916

# Submission time Handle Problem Language Result Execution time Memory
484916 2021-11-05T17:52:46 Z Bench0310 Hotel (CEOI11_hot) C++17
40 / 100
4000 ms 20804 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,o;
    cin >> n >> m >> o;
    vector<array<int,2>> ini(n+1,{0,0});
    for(int i=1;i<=n;i++) cin >> ini[i][1] >> ini[i][0];
    sort(ini.begin(),ini.end());
    vector<int> p(n+1,0);
    vector<int> c(n+1,0);
    for(int i=1;i<=n;i++)
    {
        p[i]=ini[i][0];
        c[i]=ini[i][1];
    }
    vector<bool> vis(n+1,0);
    vector<array<int,2>> v(m);
    for(auto &[d,x]:v)
    {
        cin >> x >> d;
        int idx=1;
        while(idx<=n&&p[idx]<d) idx++;
        d=idx;
    }
    ll res=0;
    while(o>0)
    {
        array<int,3> mx={0,0};
        for(int i=0;i<m;i++)
        {
            auto [d,x]=v[i];
            if(d==n+1) continue;
            int j=d;
            while(j<=n&&vis[j]) j++;
            if(j<=n) mx=max(mx,{x-c[j],i,j});
        }
        auto [r,i,j]=mx;
        if(r>=0)
        {
            res+=r;
            v.erase(v.begin()+i);
            vis[j]=1;
            o--;
        }
        else break;
    }
    cout << res << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 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 Runtime error 2 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 75 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4085 ms 2776 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 4074 ms 4640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4067 ms 10776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4043 ms 18440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4067 ms 20804 KB Time limit exceeded
2 Halted 0 ms 0 KB -