Submission #710585

# Submission time Handle Problem Language Result Execution time Memory
710585 2023-03-15T11:47:39 Z WonderfulWhale Hotel (CEOI11_hot) C++17
70 / 100
4000 ms 16868 KB
#include<bits/stdc++.h>
using namespace std;

#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

pii tab[500009];
bool vis[500009];

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m, o;
	cin >> n >> m >> o;
	for(int i=0;i<n;i++) {
		cin >> tab[i].st >> tab[i].nd;
	}
	sort(tab, tab+n);
	vector<pii> v(m);
	for(int i=0;i<m;i++) {
		cin >> v[i].st >> v[i].nd;
		v[i].st*=-1;
	}
	sort(all(v));
	vector<int> ans;
	for(pii x:v) {
		x.st = -x.st;
		for(int i=0;i<n;i++) {
			if(!vis[i]&&tab[i].nd>=x.nd&&tab[i].st<x.st) {
				ans.pb(-(x.st-tab[i].st));
				vis[i] = true;
				break;
			}
		}
	}
	int res = 0;
	sort(all(ans));
	for(int i=0;i<min(sz(ans), o);i++) {
		res -= ans[i];
	}
	cout << res << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1206 ms 2124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3148 ms 3136 KB Output is correct
2 Correct 1799 ms 4272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4016 ms 7408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4021 ms 13716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4061 ms 16868 KB Time limit exceeded
2 Halted 0 ms 0 KB -