Submission #397080

#TimeUsernameProblemLanguageResultExecution timeMemory
397080Nicholas_PatrickSure Bet (CEOI17_sure)C++17
100 / 100
91 ms4368 KiB
#include <cstdio> #include <queue> #include <cmath> #include <algorithm> using namespace std; int main(){ int n; scanf("%d", &n); vector<int> a(n), b(n); for(int i=n; i--;){ double x, y; scanf("%lf%lf", &x, &y); a[i]=x*10000+0.1; b[i]=y*10000+0.1; } sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); vector<long long> psa(n+1), psb(n+1); psa[0]=psb[0]=0; for(int i=0; i<n; i++){ psa[i+1]=psa[i]+a[i]; psb[i+1]=psb[i]+b[i]; } long long best=0; for(int i=0; i<=n; i++){ int low=0, high=n, mid;//candy[] while(low<=high){ mid=low+high>>1; long long tota=psa[mid]-(mid+i)*10000; long long totb=psb[i]-(mid+i)*10000; best=max(best, min(tota, totb)); if(tota<totb){ low=mid+1; }else{ high=mid-1; } } } printf("%.4lf\n", best/10000.0); }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:29:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   29 |    mid=low+high>>1;
      |        ~~~^~~~~
sure.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
sure.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   scanf("%lf%lf", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...