Submission #860160

# Submission time Handle Problem Language Result Execution time Memory
860160 2023-10-11T20:54:19 Z lovrot Hotel (CEOI11_hot) C++17
30 / 100
530 ms 40352 KB
#include <cstdio> 
#include <vector> 
#include <algorithm> 
#include <set> 

#define X first
#define Y second
#define EB emplace_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int n, m, k;
set<pll> A;
vector<pll> B;

vector<ll> ANS;

int main() {
	scanf("%d%d%d", &n, &m, &k); 
	for(int i = 0; i < n; ++i) {
		int a, b;
		scanf("%d%d", &a, &b); 
		A.insert({b, a}); 
	}
	for(int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b); 
		B.EB(MP(a, b));
	}
	sort(B.begin(), B.end(), [](pll a, pll b) { return a.X > b.X || (a.X == b.X && a.Y < b.Y); });
	for(pll p : B) {
		auto lb = A.lower_bound(MP(p.Y, 0));
		if(lb != A.end()) {
			ANS.EB(p.X - (*lb).Y);
			A.erase(lb); 
		}
	}

	sort(ANS.begin(), ANS.end(), [](ll a, ll b) { return a > b; }); 
	ll ans = 0;
	for(int i = 0; i < min(k, (int) ANS.size()) && ANS[i] > 0; ++i) ans += ANS[i];
	printf("%lld\n", ans);
	return 0;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d%d%d", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
hot.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
hot.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 424 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 4336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 63 ms 7364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 208 ms 21204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 530 ms 40352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 486 ms 27688 KB Output isn't correct
2 Halted 0 ms 0 KB -