//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << " " <<
#define nl << "\n"
int a[100000], b[100000], bet = 10000;
int f(int i, int j){
return min(a[i]-(j+1)*bet, b[j]-(i+1)*bet);
}
signed main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n; cin >> n;
for(int i=0; i<n; ++i){
string inp0, inp1; cin >> inp0 >> inp1;
int i0 = 0, i1 = 0;
int dot = 0;
for(int j=0; j<inp0.size(); ++j) if(inp0[j]=='.') dot = j;
if(!dot){
inp0 += ".0000";
}else{
dot = 4-(inp0.size()-dot-1);
for(int j=0; j<dot; ++j) inp0 += "0";
}
dot = 0;
for(int j=0; j<inp1.size(); ++j) if(inp1[j]=='.') dot = j;
if(!dot){
inp1 += ".0000";
}else{
dot = 4-(inp1.size()-dot-1);
for(int j=0; j<dot; ++j) inp1 += "0";
}
for(char j : inp0){
if(j=='.') continue;
i0 *= 10LL;
i0 += (j-'0');
}
for(char j : inp1){
if(j=='.') continue;
i1 *= 10LL;
i1 += (j-'0');
}
a[i] = i0 - bet;
b[i] = i1 - bet;
}
sort(a, a+n, greater<>());
sort(b, b+n, greater<>());
for(int i=1; i<n; ++i){
a[i] += a[i-1];
b[i] += b[i-1];
}
int ans = 0, sub = 0;
int i = 0, j = 0;
while(i < n and j < n){
while(i+1<n and f(i+1, j) >= f(i, j)) ++i;
ans = max(ans, f(i, j));
++j;
}
double out = (double)ans;
out /= 10000.0;
cout << fixed << setprecision(4);
cout << out nl;
}
Compilation message
sure.cpp: In function 'int main()':
sure.cpp:22:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for(int j=0; j<inp0.size(); ++j) if(inp0[j]=='.') dot = j;
| ~^~~~~~~~~~~~
sure.cpp:31:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(int j=0; j<inp1.size(); ++j) if(inp1[j]=='.') dot = j;
| ~^~~~~~~~~~~~
sure.cpp:58:18: warning: unused variable 'sub' [-Wunused-variable]
58 | int ans = 0, sub = 0;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
36 ms |
3292 KB |
Output is correct |
18 |
Correct |
36 ms |
3308 KB |
Output is correct |
19 |
Correct |
37 ms |
3308 KB |
Output is correct |
20 |
Correct |
36 ms |
3308 KB |
Output is correct |
21 |
Correct |
39 ms |
3692 KB |
Output is correct |
22 |
Correct |
36 ms |
3308 KB |
Output is correct |
23 |
Correct |
37 ms |
3436 KB |
Output is correct |
24 |
Correct |
37 ms |
3308 KB |
Output is correct |
25 |
Correct |
36 ms |
3308 KB |
Output is correct |
26 |
Correct |
39 ms |
3692 KB |
Output is correct |