# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
546359 | 2022-04-07T11:17:17 Z | AJ00 | Rice Hub (IOI11_ricehub) | C++14 | 1000 ms | 596 KB |
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; int besthub(int R, int L, int X[], long long B) { int ans; int n = R; long long int lsum,rsum; deque<int> le,re; int f = 1, b = n; while(f != b){ int mid = ((f+b) >> 1); lsum = rsum = 0; le.clear(); re.clear(); for (int i = 0; i < (mid+1)/2; i++){ lsum += X[i]; le.push_back(X[i]); } for (int i = (mid+1)/2; i < mid; i++){ rsum += X[i]; re.push_back(X[i]); } /*if (mid%2==1){ int nxt = re.front(); re.pop_front(); rsum -= nxt; lsum += nxt; }*/ bool pos = false; if (rsum - lsum < B){ f = mid; continue; } int nxt,temp1,temp2,itr = mid+1; while(itr < n){ nxt = X[itr]; temp1 = re.front(); temp2 = le.front(); rsum += (nxt-temp1); lsum += (temp1-temp2); re.pop_front(); le.pop_front(); re.push_back(nxt); le.push_back(temp1); if (rsum - lsum <= B){ pos = true; break; } itr++; } if (pos){ f = mid; } else { b = mid-1; } } return f; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 260 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Execution timed out | 1083 ms | 212 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1070 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 596 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |