Submission #1085297

#TimeUsernameProblemLanguageResultExecution timeMemory
1085297LeonidCukSure Bet (CEOI17_sure)C++17
0 / 100
1 ms1112 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; vector<double>v1,v2,p1,p2,ans(100001); double vidi(int n) { double a=0; for(int i=0;i<=n;i++) { double b=min(p1[i],p2[n-i]); if(b>a) { a=b; } } return a-double(n); } int main() { int n; double a,b,ans=0; cin>>n; for(int i=0;i<n;i++) { cin>>a>>b; v1.push_back(a); v2.push_back(b); } sort(v1.begin(),v1.end(),greater<double>()); sort(v2.begin(),v2.end(),greater<double>()); p1.push_back(0); p2.push_back(0); for(int i=0;i<n;i++) { p1.push_back(p1[i]+v1[i]); p2.push_back(p2[i]+v2[i]); } for(int i=0;i<=n;i++) { if(p1[n-i]<=p2[i]) { continue; } double temp=min(p1[n-i],p2[i])-n; int l=0,r=i,lt=0,rt=temp; ans=max(temp,ans); while(l<r) { int m=(l+r)/2; temp=min(p1[n-i],p2[m])-(n-i)-m; if(temp<rt) { l=m+1; lt=temp; } else { r=m; rt=temp; } ans=max(temp,ans); } } for(int i=0;i<=n;i++) { if(p2[n-i]<=p1[i]) { continue; } double temp=min(p2[n-i],p1[i])-n; int l=0,r=i,lt=0,rt=temp; ans=max(temp,ans); while(l<r) { int m=(l+r)/2; temp=min(p2[n-i],p1[m])-(n-i)-m; if(temp<rt) { l=m+1; lt=temp; } else { r=m; rt=temp; } ans=max(temp,ans); } } cout<<fixed<<setprecision(4)<<ans; return 0; }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:45:21: warning: variable 'lt' set but not used [-Wunused-but-set-variable]
   45 |         int l=0,r=i,lt=0,rt=temp;
      |                     ^~
sure.cpp:71:21: warning: variable 'lt' set but not used [-Wunused-but-set-variable]
   71 |         int l=0,r=i,lt=0,rt=temp;
      |                     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...