제출 #860157

#제출 시각아이디문제언어결과실행 시간메모리
860157lovrotHotel (CEOI11_hot)C++17
0 / 100
475 ms56576 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...