Submission #878667

# Submission time Handle Problem Language Result Execution time Memory
878667 2023-11-25T04:02:47 Z Jawad_Akbar_JJ Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 2396 KB
#include <iostream>
#include <vector>
#include <iomanip>
 
using namespace std;
#define ld long double 
const int N = 1e5  + 10;
vector<int> v;
ld a[N];
ld b[N];
int n;
ld ans = 0;

bool valid(int ind = n){
	if (ind==0)
		return false;
	if (v[ind]<3){
		v[ind]++;
		return true;
	}
	v[ind] = 0;
	return valid(ind-1);
}

void calculate(){
	ld sum1 = 0,sum2 = 0;
	ld cnt = 0;
	
	for (int i=1;i<=n;i++)
		if (v[i]==1 or v[i] == 3)
			sum1 += a[i],cnt++;
		else if (v[i] == 2 or v[i] == 3)
			sum2 += b[i],cnt++;
			
	ans = max(ans,min(sum1,sum2) - cnt);
}

signed main(){
	cout<<fixed<<setprecision(4);
	cin>>n;
	
	for (int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	
	for (int i=0;i<=n;i++)
		v.push_back(0);
	
	while (valid()){
		calculate();	
	}
	cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -