# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
329488 | 2020-11-21T10:17:54 Z | dolphingarlic | Circus (Balkan15_CIRCUS) | C++14 | 43 ms | 13268 KB |
#include "circus.h" #include <bits/stdc++.h> using namespace std; struct State { int cost, idx, change_cnt; bool dir; // Left = 0 }; bool operator<(State A, State B) { return A.cost > B.cost; } int n, m, p[100001], mn[100001]; void init(int N, int M, int P[]){ n = N, m = M; memcpy(p, P, sizeof p); sort(p, p + n); p[n] = m; memset(mn, 0x3f, sizeof mn); priority_queue<State> pq; pq.push({mn[n] = 0, n, 0, 0}); while (pq.size()) { State curr = pq.top(); pq.pop(); if (curr.cost != mn[curr.idx]) continue; for (int i = 0; i < curr.idx; i++) { if (p[curr.idx] - p[i] >= curr.cost) { if (p[curr.idx] - p[i] < mn[i]) { pq.push({mn[i] = p[curr.idx] - p[i], i, curr.change_cnt + curr.dir, 0}); } } // else break; } if (curr.change_cnt != 2) { for (int i = n - 1; i > curr.idx; i++) { if (p[i] - p[curr.idx] >= curr.cost) { if (p[i] - p[curr.idx] < mn[i]) { pq.push({mn[i] = p[i] - p[curr.idx], i, curr.change_cnt + !curr.dir, 1}); } } // else break; } } } } int minLength(int D) { int ans = m - D; for (int i = 0; i < n; i++) if (abs(D - p[i]) >= mn[i]) { ans = min(ans, abs(D - p[i])); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 43 ms | 13268 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 2028 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 2028 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 2028 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 43 ms | 13268 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 43 ms | 13268 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |