Submission #860157

# Submission time Handle Problem Language Result Execution time Memory
860157 2023-10-11T20:37:59 Z lovrot Hotel (CEOI11_hot) C++17
0 / 100
475 ms 56576 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 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 5844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 10024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 177 ms 27328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 475 ms 56576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 459 ms 44088 KB Output isn't correct
2 Halted 0 ms 0 KB -