# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076678 | 2024-08-26T15:31:44 Z | allin27x | Radio Towers (IOI22_towers) | C++17 | 4000 ms | 5880 KB |
#include <bits/stdc++.h> using namespace std; #define int long long vector<int> h; vector<int> lc,rc,a; void init(signed N, std::vector<signed> H){ h.resize(N); for (int i = 0; i < N; i++) h[i] = H[i]; } int dfs(int i, int d){ if (i==-1) return 0; if (lc[i]==-1 && rc[i]==-1) return -a[i]; int lans = dfs(lc[i],d); int rans = dfs(rc[i],d); if (lans < 0 && a[i] - d >= a[lc[i]]) lans = 1; if (rans < 0 && a[i] - d >= a[rc[i]]) rans = 1; if (!lans) return rans; if (!rans) return lans; if (lans < 0 && rans < 0) return max(lans,rans); if (lans < 0) return rans; if (rans < 0) return lans; return lans + rans; } signed max_towers(signed l, signed r, signed d){ int sz = r-l+1; a.assign(sz,0); for (int i=l; i<=r; i++) a[i-l] = h[i]; a.push_back(1e18); stack<int> st; st.push(sz); lc.assign(sz+1,-1); rc.assign(sz+1,-1); for (int i=0; i<sz; i++){ int last = -1; while (a[i] > a[st.top()]) { last=st.top(); st.pop(); } lc[i] = last; rc[st.top()]=i; st.push(i); } return dfs(sz,d); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4083 ms | 5880 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | 1st lines differ - on the 1st token, expected: '292', found: '271' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | 1st lines differ - on the 1st token, expected: '292', found: '271' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4075 ms | 5428 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4037 ms | 1180 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | 1st lines differ - on the 1st token, expected: '292', found: '271' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4083 ms | 5880 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |