Submission #309545

#TimeUsernameProblemLanguageResultExecution timeMemory
309545biggSure Bet (CEOI17_sure)C++14
60 / 100
2069 ms4984 KiB
#include<bits/stdc++.h> using namespace std; typedef double ll; const int MAXN = 1e5 + 10; ll prefa[MAXN], prefb[MAXN], a[MAXN], b[MAXN]; int n; int main(){ scanf("%d", &n ); for(int i = 1; i <= n; i++){ scanf("%lf %lf", &a[i], &b[i]); } sort(a + 1, a + 1 + n); sort(b + 1, b + 1 + n); for(int i = 1; i <= n; i++){ prefb[i] = prefb[i-1] + b[i]; prefa[i] = prefa[i-1] + a[i]; } double ans = 0; for(int numa = 0; numa <= n; numa++){ for(int numb = 0; numb <= n; numb++){ double bloc = prefb[n] - prefb[n - numb]; double aloc = prefa[n] - prefa[n - numa]; //printf("%lf %lf\n", bloc, aloc ); ans = max(ans, min(bloc - numb - numa, aloc - numa - numb)); } } printf("%.4lf\n", ans); }

Compilation message (stderr)

sure.cpp: In function 'int main()':
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:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |   scanf("%lf %lf", &a[i], &b[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...