Submission #967842

# Submission time Handle Problem Language Result Execution time Memory
967842 2024-04-23T01:53:50 Z ByeWorld Sure Bet (CEOI17_sure) C++14
60 / 100
2000 ms 8876 KB
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
const int MAXN = 2e5+10;
const int INF = 4e18+10;
typedef pair<int,int> pii;
typedef pair<pii,int> ipii;
const int MX = 1e9+10;

int n;
vector <ld> vec, vec2;
ld pr[MAXN], pref[MAXN];

signed main(){
	// ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	for(int i=1; i<=n; i++){
		ld x, y; cin >> x >> y;
		vec.pb(x); vec2.pb(y);
	}
	vec.pb(INF); vec2.pb(INF);
	sort(vec.rbegin(), vec.rend());
	sort(vec2.rbegin(), vec2.rend());
	ld ANS = 0;
	for(int i=1; i<vec.size(); i++){
		pr[i] = pr[i-1]+vec[i];
	}
	for(int i=1; i<vec2.size(); i++){
		pref[i] = pref[i-1]+vec2[i];
	}
	for(int i=0; i<vec.size(); i++){
		for(int j=0; j<vec2.size(); j++){
			ANS = max(ANS, min(pr[i], pref[j])-i-j);
			// cout << i<< ' ' << j << ' ' << pr[i]+pref[j]-i-j <<  " p\n";
		}
	}
	// while(l<=vec.size() && r<=vec2.size()){
	// 	if(r==vec2.size() || le < ri){
	// 		le--; ri--;
	// 		le += vec[l];
	// 		l++;
	// 	} else {
	// 		le--; ri--;
	// 		ri += vec2[r];
	// 		r++;
	// 	}
	// 	// cout << le << ' '<< ri << " leri\n";
	// 	ANS = max(ANS, min(le, ri));
	// }
	printf("%.4lf",(double)ANS);
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:33:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for(int i=1; i<vec.size(); i++){
      |               ~^~~~~~~~~~~
sure.cpp:36:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for(int i=1; i<vec2.size(); i++){
      |               ~^~~~~~~~~~~~
sure.cpp:39:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i=0; i<vec.size(); i++){
      |               ~^~~~~~~~~~~
sure.cpp:40:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int j=0; j<vec2.size(); j++){
      |                ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 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 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 444 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 5 ms 564 KB Output is correct
14 Correct 5 ms 348 KB Output is correct
15 Correct 5 ms 348 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 444 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 5 ms 564 KB Output is correct
14 Correct 5 ms 348 KB Output is correct
15 Correct 5 ms 348 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Execution timed out 2035 ms 8876 KB Time limit exceeded
18 Halted 0 ms 0 KB -