# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169437 | 2019-12-20T10:46:36 Z | Ruxandra985 | Sure Bet (CEOI17_sure) | C++14 | 2 ms | 376 KB |
/// pe langa faptul ca sunt inteligenta si nu stiu sa citesc enunturi /// cateodata mai si uit sa trec pe standard input/output si iau 0 degeaba:) #include <bits/stdc++.h> #define DIMN 100010 using namespace std; double v[DIMN],w[DIMN] , spv[DIMN] , spw[DIMN]; double check (int x , int y){ return min(spv[x] - x - y , spw[y] - x - y); } int main() { FILE *fin = stdin; int n , i , j , taken = 0 , st , dr , mid , nr; double sol = 0.0 ,x , y, z; fscanf (fin,"%d",&n); for (i=1;i<=n;i++){ fscanf (fin,"%lf%lf",&v[i],&w[i]); } sort (v+1 , v + n + 1); sort (w+1 , w + n + 1); for (i=1;i<=n-i+1;i++){ swap(v[i] , v[n-i+1]); swap(w[i] , w[n-i+1]); } for (i=1;i<=n;i++){ spv[i] = spv[i-1] + v[i]; spw[i] = spw[i-1] + w[i]; } spv[0] = spw[0] = -2000000000; spv[n+1] = spw[n+1] = 2000000000; for (i=1;i<=n;i++){ /// avem spv[i] /// pot sa caut ternar sol pe w st = 1; dr = n; nr = 100; while (st <= dr && nr){ mid = (st + dr)/2; x = check(i , mid-1); y = check(i , mid); z = check(i , mid+1); if (x <= y && y <= z){ /// solutie sol = max(sol , min(spv[i] - i - mid , spw[mid] - i - mid)); break; } else if (x <= y && y <= z) st = mid; else dr = mid; nr--; } sol = max(sol , min(spv[i] - i - mid , spw[mid] - i - mid)); } cout << setprecision(4) << fixed << sol; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |