Submission #607410

# Submission time Handle Problem Language Result Execution time Memory
607410 2022-07-26T16:55:37 Z UncoolAnon Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h> 
using namespace std; 
int main(){
	freopen("in.txt","r",stdin); 
	freopen("out.txt","w",stdout); 
	int n; 
	cin>>n; 
	vector<double> a(n),b(n); 
	for(int i=0;i<n;i++) cin>>a[i]>>b[i]; 
	double answer=0; 
	vector<int> A,B; 
	double curA=0,num=0;  
	for(int i=0;i<n;i++){
		if(a[i]<1&&b[i]<1){}
		else{
			A.push_back(i); 
			B.push_back(i); 
		}
	}
	sort(A.begin(),A.end(),[&](int i,int j){
		if(a[i]==a[j]) return b[i]>b[j]; 
		return a[i]>a[j]; 
	}); 
	sort(B.begin(),B.end(),[&](int i,int j){
		if(b[i]==b[j]) return a[i]>a[j]; 
		return b[i]>b[j]; 
	}); 
	for(int&i:A){
		++num; 
		curA+=a[i]; 
		double curB=0; 
		for(int&j:B){
			curB+=b[j]; 
			++num;
			answer=max(answer,min(curB,curA)-num); 
		}
		num-=B.size(); 
	}
	cout<<answer; 
	return 0; 
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:4:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 |  freopen("in.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~
sure.cpp:5:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |  freopen("out.txt","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -