# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1028385 |
2024-07-19T18:31:27 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
1 ms |
348 KB |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define deb(x) cout<<#x<<": "<<x<<endl;
using lli=long long int;
using ld=long double;
void solve(){
lli n=1;
// deb(n);
cin>>n;
// deb(n);
vector<ld> v1(n);
vector<ld> v2(n);
for(lli i=0; i<n; ++i){
cin>>v1[i]>>v2[i];
// deb(v1[i]);
// deb(v2[i]);
}
sort(v1.rbegin(), v1.rend());
sort(v2.rbegin(), v2.rend());
ld ans=0;
vector<ld> v3=v2;
v3[0]--;
for(lli i=1; i<n; ++i){
v3[i]+=v3[i-1]-1;
}
for(lli i=1; i<n; ++i){
v3[i]=max(v3[i],v3[i-1]);
// deb(v3[i]);
}
ld sum1=0;
ld sum2=0;
lli j=0;
for(lli i=0; i<n ; ++i){
sum1+=v1[i];
while(j<n && sum2<sum1){
sum2+=v2[j];
j++;
}
ld aux;
if(j>=2){
aux=v3[j-2]-i-1;
}
else aux=0;
aux=max(aux, sum1-i-1-j);
ans=max(ans, aux);
}
cout<<setprecision(4)<<fixed<<ans<<endl;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
lli t=1;
//cin>>t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |