#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(),x.end()
#define pb push_back
#define ent "\n"
const int maxn = (int)3e5 + 13;
const ll inf = (long long)1e18 + 20;
const int mod = (int)1e9 + 7;
int n;
pair<ld,ld>a[maxn];
ld pref[maxn];
int get(int x,int y){
int ans = x / pow(4,y);
ans %= 4;
return ans;
}
void solve(){
cin >> n;
for(int i = 1 ; i <= n ; i ++){
cin >> a[i].first >> a[i].second;
}
ld mx = 0;
for(int i = 0 ; i <= pow(4,n) ; i ++){
ld one = 0,sec = 0,cnt = 0;
for(int j = 0 ; j < n ; j ++){
int calc = get(i,j);
if(calc!=0){
if(calc == 1){
one+=a[j + 1].first;
}
else if(calc == 2){
sec += a[j + 1].second;
}
else{
sec += a[j + 1].second,one += a[j + 1].first;
cnt++;
}
cnt++;
}
}
mx = max(mx,min(one,sec) - cnt);
}
printf("%.4lf",(double)mx);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t --){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
420 ms |
2496 KB |
Output is correct |
4 |
Correct |
416 ms |
2396 KB |
Output is correct |
5 |
Correct |
419 ms |
2392 KB |
Output is correct |
6 |
Correct |
418 ms |
2496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
420 ms |
2496 KB |
Output is correct |
4 |
Correct |
416 ms |
2396 KB |
Output is correct |
5 |
Correct |
419 ms |
2392 KB |
Output is correct |
6 |
Correct |
418 ms |
2496 KB |
Output is correct |
7 |
Execution timed out |
2023 ms |
2392 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
420 ms |
2496 KB |
Output is correct |
4 |
Correct |
416 ms |
2396 KB |
Output is correct |
5 |
Correct |
419 ms |
2392 KB |
Output is correct |
6 |
Correct |
418 ms |
2496 KB |
Output is correct |
7 |
Execution timed out |
2023 ms |
2392 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |