#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void print(ll a) {
if(a < 10) cout << "0.000" << a;
else if(a < 100) cout << "0.00" << a;
else if(a < 1000) cout << "0.0" << a;
else if(a < 10000) cout << "0." << a;
else cout << a/10000 << "." << a%10000;
return;
}
int main() {
int n;
cin >> n;
vector<ll> v1(n), v2(n);
for(int i = 0; i<n; i++) {
double a, b;
cin >> a >> b;
a *= 10000;
b *= 10000;
v1[i] = (ll) a;
v2[i] = (ll) b;
}
sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end());
reverse(v1.begin(), v1.end()); reverse(v2.begin(), v2.end());
ll ptr1 = 0, ptr2 = 0;
ll val1 = 0, val2 = 0, rem = 0;
ll ans = 0;
while(ptr1 <= n && ptr2 <= n) {
if(val1 < val2) {
val1 += v1[ptr1];
ptr1++;
rem += 10000;
}
else{
val2+= v2[ptr2];
ptr2++;
rem += 10000;
}
ans = max(ans, min(val1, val2) - rem);
}
print(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |