#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
void output(double p1, double p2)
{
if(p1 < 0 ||p2<0)
printf("%.4lf", (double)(0));
else
printf("%.4lf", (double)(min(p1, p2)));
}
int main()
{
int n; cin>>n;
vector<long double> odds1(n), odds2(n);
for(int i = 0; i<n; ++i)
{
cin>>odds1[i]>>odds2[i];
}
sort(odds1.rbegin(), odds1.rend());
sort(odds2.rbegin(), odds2.rend());
vector<long double> prefSum1(n);
vector<long double> prefSum2(n);
prefSum1[0] = odds1[0];
prefSum2[0] = odds2[0];
for(int i =1; i<n; ++i)
{
prefSum1[i] = prefSum1[i-1]+odds1[i];
prefSum2[i] = prefSum2[i-1]+ odds2[i];
}
long double bestSureProf = 0;
for(int i = 0; i<n; ++i)
{
for(int j = 0; j<n; ++j)
{
long double p1 = prefSum1[i]- (i+1) - (j+1);
long double p2 = prefSum2[j] - (i+1) - (j+1);
if(min(p1,p2) > bestSureProf)
bestSureProf = min(p1,p2);
}
}
output(bestSureProf, bestSureProf);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
6 ms |
340 KB |
Output is correct |
13 |
Correct |
6 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
340 KB |
Output is correct |
16 |
Correct |
8 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
6 ms |
340 KB |
Output is correct |
13 |
Correct |
6 ms |
340 KB |
Output is correct |
14 |
Correct |
7 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
340 KB |
Output is correct |
16 |
Correct |
8 ms |
316 KB |
Output is correct |
17 |
Execution timed out |
2085 ms |
8016 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |