#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]<2){
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)
sum1 += a[i],cnt++;
else if (v[i]==2)
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |