Submission #743082

# Submission time Handle Problem Language Result Execution time Memory
743082 2023-05-17T07:46:56 Z Dan4Life Hotel (CEOI11_hot) C++17
40 / 100
4000 ms 32120 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(a) (int)a.size()
const int mxN = (int)5e5+10;
using ar = array<int,2>;

int n, m, k;
ar a[mxN], b[mxN];
bool taken[mxN], taken2[mxN];

int32_t main(){
	cin >> n >> m >> k;
	for(int i = 0; i < n; i++) cin >> a[i][1] >> a[i][0];
	for(int i = 0; i < m; i++) cin >> b[i][1] >> b[i][0];
	sort(a,a+n), sort(b,b+m); int ans = 0;
	while(k--){
		int mx = 0, mn = mxN*mxN, I, J;
		for(int i = 0; i < n; i++){
			if(taken[i]) continue;
			for(int j = 0; j < m; j++){
				if(taken2[j]) continue;
				if(a[i][0] < b[j][0]) continue;
				if(mx<b[j][1]-a[i][1])
					mx = b[j][1]-a[i][1], I=i,J=j;
				else if(mx==b[j][1]-a[i][1])
					if(mn>a[i][0]) mn=a[i][0],I=i,J=j;
			}
			
		}
		if(!mx) break; ans+=mx;
		taken[I]=taken2[J]=1;
	}
	cout << ans;
}

Compilation message

hot.cpp: In function 'int32_t main()':
hot.cpp:31:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |   if(!mx) break; ans+=mx;
      |   ^~
hot.cpp:31:18: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   31 |   if(!mx) break; ans+=mx;
      |                  ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4062 ms 852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4064 ms 3084 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4048 ms 5112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4062 ms 14156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4032 ms 28176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 32120 KB Time limit exceeded
2 Halted 0 ms 0 KB -