# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
856473 | 2023-10-03T15:42:36 Z | nnin | Rice Hub (IOI11_ricehub) | C++14 | 1000 ms | 636 KB |
#include "ricehub.h" #include<bits/stdc++.h> #define ll long long #define pii pair<ll,int> using namespace std; int besthub(int n, int m, int x[], long long b) { int ans = 0; int posi = x[0]; ll cost = 0; int l = 0; int r = 0; for(int i=0;i<n;i++) { if(i>0) cost += (x[i]-x[i-1])*(i-l-r+i-1); while(r<i) { cost += x[++r]-x[i]; } while(cost>b) { if(x[r]-x[i] > x[i]-x[l]) { cost -= x[r--]-x[i]; } else { cost -= x[i]-x[l++]; } } while(true) { if(r<n-1 && x[r+1]-x[i] <= x[i]-x[l]) { cost += x[++r]-x[i]; cost -= x[i]-x[l++]; } else if(l>0 && x[i]-x[l-1] <= x[r]-x[i]) { cost += x[i]-x[--l]; cost -= x[r--]-x[i]; } else if(r<n-1 && cost+x[r+1]-x[i] <= b) { cost += x[++r]-x[i]; } else if(l>0 && cost+x[i]-x[l-1] <= b) { cost += x[i]-x[--l]; } else { break; } } ans = max(ans, r-l+1); } return ans; } /* 5 20 6 1 2 10 12 14 3 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Execution timed out | 1079 ms | 348 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 444 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Execution timed out | 1096 ms | 348 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1052 ms | 348 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1024 ms | 636 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |