Submission #860158

# Submission time Handle Problem Language Result Execution time Memory
860158 2023-10-11T20:39:43 Z lovrot Hotel (CEOI11_hot) C++17
20 / 100
431 ms 40520 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;

const int N = 5e5 + 10; 

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(b, a)); 
	}
	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.X, 0));
		if(lb != A.end()) {
			ANS.EB(p.Y - (*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 < k && ANS[i] > 0; ++i) ans += ANS[i];
	printf("%lld\n", ans);
	return 0;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d%d%d", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
hot.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~
hot.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |   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 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 4368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 7360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 168 ms 20752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 431 ms 40520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 414 ms 27824 KB Output isn't correct
2 Halted 0 ms 0 KB -