# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1015799 |
2024-07-06T20:16:22 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
1 ms |
600 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n; cin>>n;
vector<double> a(n),b(n);
for (int i=0; i<n; i++) cin>>a[i]>>b[i];
sort(a.begin(),a.end(),greater<double>());
sort(b.begin(),b.end(),greater<double>());
//now take prefix sums
for (int i=1; i<n; i++){
a[i]=a[i-1]+a[i];
}
for (int i=1; i<n; i++){
b[i]=b[i-1]+b[i];
}
double ans=0;
int r=0;
for (int i=0; i<n; i++){
while (r<n and b[r]<a[i]) r++;
if (r>=n) break;
ans=max(ans, a[i]-(i+1+r+1));
}
r=0;
for (int i=0; i<n; i++){
while (r<n and a[r]<b[i]) r++;
if (r>=n) break;
ans=max(ans, b[i]-(i+1+r+1));
}
cout<<ans<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |