Submission #169261

#TimeUsernameProblemLanguageResultExecution timeMemory
169261Ruxandra985Sure Bet (CEOI17_sure)C++14
0 / 100
2 ms380 KiB
#include <bits/stdc++.h> using namespace std; double a[100010] , b[100010]; int f[100010]; int main() { FILE *fin = stdin; int n , i; double sx , sy , sol , luat; fscanf (fin,"%d",&n); sx = sy = 0.0; for (i=1;i<=n;i++){ fscanf (fin,"%lf%lf",&a[i],&b[i]); if (sx < sy || (sx == sy && a[i] > b[i])){ f[i] = 1; sx+=a[i]; } else { f[i] = 2; sy+=b[i]; } } sol = min(sx , sy) - 1.0 * n; luat = n; for (i=1;i<=n;i++){ if (f[i] == 1){ if (sol < min(sx - a[i] , sy) - 1.0 * luat + 1.0){ sol = min(sx - a[i] , sy) - 1.0 * luat + 1.0; luat--; sx-=a[i]; } } else { if (sol < min(sx , sy - b[i]) - 1.0 * luat + 1.0){ sol = min(sx , sy - b[i]) - 1.0 * luat + 1.0; luat--; sy-=b[i]; } } } cout << setprecision(4) << fixed << sol; return 0; }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:10:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d",&n);
     ~~~~~~~^~~~~~~~~~~~~
sure.cpp:13:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%lf%lf",&a[i],&b[i]);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...