Submission #1085298

#TimeUsernameProblemLanguageResultExecution timeMemory
1085298LeonidCukSure Bet (CEOI17_sure)C++17
0 / 100
1 ms1116 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,lt=0,rt=temp; int l=0,r=i; 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,lt=0,rt=temp; int l=0,r=i; 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:44:42: warning: variable 'lt' set but not used [-Wunused-but-set-variable]
   44 |         double temp=min(p1[n-i],p2[i])-n,lt=0,rt=temp;
      |                                          ^~
sure.cpp:70:42: warning: variable 'lt' set but not used [-Wunused-but-set-variable]
   70 |         double temp=min(p2[n-i],p1[i])-n,lt=0,rt=temp;
      |                                          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...