Submission #160256

#TimeUsernameProblemLanguageResultExecution timeMemory
160256AkashiSure Bet (CEOI17_sure)C++14
0 / 100
8 ms256 KiB
#include <bits/stdc++.h> using namespace std; int n; double a[100005], b[100005]; int main() { // freopen("1.in", "r", stdin); scanf("%d", &n); for(int i = 1; i <= n ; ++i) scanf("%lf %lf", &a[i], &b[i]); sort(a + 1, a + n + 1); sort(b + 1, b + n + 1); double st = 0, dr = 1e9; int pasi = 69; while(pasi--){ double mij = (st + dr) / 2; int i = n, j = n, cost = 0; double sum1 = 0, sum2 = 0; while(i >= 0 && j >= 0){ if(sum1 - cost >= mij && sum2 - cost >= mij) break ; if(sum1 - cost < mij){ ++cost; sum1 += a[i--]; } else{ ++cost; sum2 += b[j--]; } } if(sum1 - cost < mij || sum2 - cost < mij) dr = mij; else st = mij; } printf("%f", st); return 0; }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
sure.cpp:11:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n ; ++i) 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...