Submission #938408

# Submission time Handle Problem Language Result Execution time Memory
938408 2024-03-05T06:04:12 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 452 KB
#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long double

using namespace std;

//int pow(int a,int b,int m){int ans=1;while(b){if(b&1){ans=(ans*a)%m;}b>>=1;a=(a*a)%m;}return ans;}
//int binpow(int a,int b){int ans=1;while(b){if(b&1){ans=(ans*a);}b>>=1;a=(a*a);}return ans;}
  
const int N = 2e5 + 10,  inf = 1e18;

main(){
	iostream::sync_with_stdio(false);  
    cin.tie(nullptr);
    cout.tie(nullptr);
    int32_t n;
    cin >> n;
    vector <int> a(n), b(n);
    for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	int ans = 0;
	sort(rall(a));
	sort(rall(b));
	int l = 0, r = 0, suma = 0, sumb = 0;
	while(l < n || r < n){
		if(suma < sumb && l < n){
			suma += a[l++];
		}else if(sumb < suma && r < n){
			sumb += b[r++];
		}else{
			if(l < n){
				suma += a[l++];
			}else if(r < n){
				sumb += b[r++];
			}else
				break;
		}
		ans = max(ans, min(sumb,suma) - l - r);
	}
	cout << fixed << setprecision(5) << ans;
}

Compilation message

sure.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 452 KB Output isn't correct
2 Halted 0 ms 0 KB -