# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
784221 | 2023-07-15T21:31:31 Z | GordonRemzi007 | Radio Towers (IOI22_towers) | C++17 | 4000 ms | 2860 KB |
#include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int> a; bool srt(pair<int,int> a, pair<int,int> b) { return a.first < b.first; } void init(int n, vector<int> h) { a = h; } int max_towers(int l, int r, int d) { int res = 0, f, s; bool ok; vector<bool> used(a.size(), false); vector<pair<int,int>> b(r-l+1); for(int i = l; i <= r; i++) b[i] = {a[i], i}; sort(b.begin(), b.end(), srt); for(int i = 0; i < b.size(); i++) { f = b[i].second, s = b[i].second; ok = true; //find closest left and right a[i] >= a[b[i].second]+d for(; f >= l; f--) { if(used[f]) { ok = false; break; } if(a[f] >= a[b[i].second]+d) break; if(f == l) { f = b[i].second; break; } } for(; s <= r; s++) { if(used[s]) { ok = false; break; } if(a[s] >= a[b[i].second]+d) break; if(s == r) { s = b[i].second; break; } } if(ok) { used[b[i].second] = true; res++; } } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 145 ms | 1884 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '13', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '13', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 17 ms | 2860 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4099 ms | 720 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '13', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 145 ms | 1884 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |