# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1042654 | 2024-08-03T09:04:57 Z | gyg | Pyramid Base (IOI08_pyramid_base) | C++17 | 5000 ms | 80220 KB |
#include <bits/stdc++.h> using namespace std; #define int long long const int MAX_N = 4e5 + 5, MAX_R = 1e6 + 5, INF = 1e18; int r, c, k, n; array<int, MAX_N> row1, col1, row2, col2, cost; array<int, 4 * MAX_R> st; void update(int l, int r, int x) { for (int i = l; i <= r; i++) st[i] += x; } int query(int l, int r) { int ans = INF; for (int i = l; i <= r; i++) ans = min(ans, st[i]); return ans; } bool check(int s) { fill(st.begin(), st.end(), 0); array<vector<int>, MAX_R> ins, del; for (int i = 1; i <= n; i++) { ins[max(col1[i] - s + 1, 1ll)].push_back(i); del[col2[i]].push_back(i); } for (int col = 1; col <= c - s + 1; col++) { for (int i : ins[col]) update(max(row1[i] - s + 1, 1ll), row2[i], cost[i]); if (query(1, r - s + 1) <= k) { // cout << s << " " << col << ": " << query(1, r - s + 1) << endl; return true; } for (int i : del[col]) update(max(row1[i] - s + 1, 1ll), row2[i], -cost[i]); } return false; } int bin_search() { int lo = 1, hi = min(r, c); while (lo != hi) { int mid = ceil((lo + hi) / (double) 2); // cout << mid << ": " << check(mid) << endl; if (check(mid)) lo = mid; else hi = mid - 1; } if (!check(lo)) return 0; return lo; } signed main() { freopen("pbs.in", "r", stdin), freopen("pbs.out", "w", stdout); cin >> r >> c >> k >> n; for (int i = 1; i <= n; i++) cin >> row1[i] >> col1[i] >> row2[i] >> col2[i] >> cost[i]; int ans = bin_search(); cout << ans << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5033 ms | 80200 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5037 ms | 80216 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5067 ms | 80168 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5023 ms | 80208 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5046 ms | 80208 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5038 ms | 80216 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5049 ms | 80212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5071 ms | 80220 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5054 ms | 80208 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5067 ms | 80212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5010 ms | 80212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5032 ms | 80216 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5049 ms | 80220 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5059 ms | 80212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5066 ms | 80220 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |