# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169261 | 2019-12-19T11:30:38 Z | Ruxandra985 | Sure Bet (CEOI17_sure) | C++14 | 2 ms | 380 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 380 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 380 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 380 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |