Submission #967829

# Submission time Handle Problem Language Result Execution time Memory
967829 2024-04-23T01:13:34 Z ByeWorld Sure Bet (CEOI17_sure) C++14
0 / 100
0 ms 348 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;

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);
	}
	sort(vec.rbegin(), vec.rend());
	sort(vec2.rbegin(), vec2.rend());
	ld ANS = 0, le = 0, ri = 0, l = 0, r = 0, pref = 0;
	for(int i=0; i<vec.size(); i++){
		pref += vec[i]; 
		ri = -i-1; le = pref-i-1;
		for(int j=0; j<vec2.size(); j++){
			ri += vec2[j]; le--; ri--;
			ANS = max(ANS, min(le, ri));
		}
	}
	le = 0; ri = 0;
	for(int i=0; i<vec.size(); i++){
		le += vec[i]; le--; ri--;
		ANS = max(ANS, min(le, ri));
	}
	le = 0; ri = 0;
	for(int i=0; i<vec2.size(); i++){
		ri += vec2[i]; le--; ri--;
		ANS = max(ANS, min(le, ri));
	}
	// 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));
	// }
	cout << fixed << setprecision(10) << ANS<< '\n';
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:31: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]
   31 |  for(int i=0; i<vec.size(); i++){
      |               ~^~~~~~~~~~~
sure.cpp:34: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]
   34 |   for(int j=0; j<vec2.size(); j++){
      |                ~^~~~~~~~~~~~
sure.cpp:40: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]
   40 |  for(int i=0; i<vec.size(); i++){
      |               ~^~~~~~~~~~~
sure.cpp:45: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]
   45 |  for(int i=0; i<vec2.size(); i++){
      |               ~^~~~~~~~~~~~
sure.cpp:30:30: warning: unused variable 'l' [-Wunused-variable]
   30 |  ld ANS = 0, le = 0, ri = 0, l = 0, r = 0, pref = 0;
      |                              ^
sure.cpp:30:37: warning: unused variable 'r' [-Wunused-variable]
   30 |  ld ANS = 0, le = 0, ri = 0, l = 0, r = 0, pref = 0;
      |                                     ^
# 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 0 ms 348 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 -