# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
787057 | 2023-07-18T17:35:51 Z | JoenPoenMan | 쌀 창고 (IOI11_ricehub) | C++17 | 1000 ms | 2072 KB |
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define ALL(arr) begin(arr), end(arr) #define CONTAINS(arr, val) (find(ALL(arr), val) == end(arr)) typedef pair<int, int> ii; int besthub(int R, int L, int X[], long long B) { vector<int> crs; stack<ii> removed; long long cost = 0; int i = 0; int best = 0; long long dc = 0; for (int x = 1; x <= L && i < R; x++) { while (!removed.empty() && removed.top().first + x - removed.top().second <= B - cost) { crs.insert(crs.begin(), removed.top().first + x - removed.top().second); cost += crs[0]; dc++; removed.pop(); } while (i < R && cost + (X[i]-x) <= B) { crs.push_back(x - X[i]); cost += X[i]-x; dc--; i++; } while (crs.size() && i < R && (X[i]-x) <= crs[0]) { cost -= crs[0]; removed.push({crs[0], x}); crs.erase(crs.begin()); crs.push_back(x - X[i]); cost += X[i]-x; dc -= 2; i++; } while (i < R && cost + (X[i]-x) <= B) { crs.push_back(x - X[i]); cost += X[i]-x; dc--; i++; } best = max(best, (int)crs.size()); for (int &el : crs) { if (el == 0) { dc += 2; } el++; } cost += dc; while (cost > B) { cost -= crs[0]; removed.push({crs[0], x}); crs.erase(crs.begin()); dc--; } if (R-1 - i < best - crs.size()) break; } return best; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 308 KB | Output is correct |
21 | Correct | 1 ms | 308 KB | Output is correct |
22 | Correct | 1 ms | 320 KB | Output is correct |
23 | Correct | 2 ms | 212 KB | Output is correct |
24 | Correct | 2 ms | 312 KB | Output is correct |
25 | Correct | 2 ms | 212 KB | Output is correct |
26 | Correct | 2 ms | 212 KB | Output is correct |
27 | Incorrect | 1 ms | 212 KB | Output isn't correct |
28 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 302 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 312 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 4 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 312 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Incorrect | 4 ms | 212 KB | Output isn't correct |
19 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 468 KB | Output is correct |
2 | Correct | 12 ms | 680 KB | Output is correct |
3 | Correct | 10 ms | 2068 KB | Output is correct |
4 | Execution timed out | 1069 ms | 2072 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |