QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#542351 | #4563. Radio Towers | Wansur | 0 | 3ms | 13392kb | C++23 | 2.0kb | 2024-09-01 00:42:44 | 2024-09-01 00:42:46 |
Judging History
answer
#include "towers.h"
#include <bits/stdc++.h>
#define ent '\n'
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 12;
int dp[maxn], a[maxn];
int p[20][maxn], lg[maxn];
int n, d;
struct segtree{
int t[maxn * 4];
segtree(){
for(int i=0;i<maxn*4;i++){
t[i] = 0;
}
}
void upd(int v, int tl, int tr, int pos, int x){
if(tl == tr){
t[v] = x;
}
else{
int mid = tl + tr >> 1;
if(pos <= mid){
upd(v*2, tl, mid, pos, x);
}
else{
upd(v*2+1, mid+1, tr, pos, x);
}
t[v] = max(t[v*2], t[v*2+1]);
}
}
int get(int v, int tl, int tr, int l, int r){
if(tl > r || l > tr) return 0;
if(tl >= l && tr <= r) return t[v];
int mid = tl + tr >> 1;
return max(get(v*2, tl, mid, l, r), get(v*2+1, mid+1, tr, l, r));
}
} ft, st;
int get(int l, int r){
if(l > r) return 0;
int k = lg[r - l + 1];
return max(p[k][l], p[k][r - (1 << k) + 1]);
}
void init(int N, std::vector<int> H) {
n = N;
for(int i=1;i<=n;i++){
a[i] = p[0][i] = H[i - 1];
if(i > 1) lg[i] = lg[i / 2] + 1;
}
for(int k=1;k<20;k++){
for(int i=1;i + (1 << k) - 1 <= n;i++){
p[k][i] = max(p[k-1][i], p[k-1][i + (1 << (k - 1))]);
}
}
}
int max_towers(int l, int r, int D) {
d = D;
l++, r++;
vector<int> ord;
for(int i=l;i<=r;i++){
ord.push_back(i);
}
sort(ord.begin(), ord.end(), [](int i, int j){
return a[i] < a[j];
});
set<int> s;
for(int i:ord){
auto it = s.upper_bound(i);
bool ok = 1;
ok &= (it == s.end() || get(i + 1, *it - 1) - d >= a[i]);
if(s.size() && it != s.begin()){
it--;
ok &= (get(*it+1, i-1) - d >= a[i]);
}
if(ok) s.insert(i);
else break;
}
return s.size();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
59640 49885 57346 58504 87383 113182 129676 204090 205404 259925 276583 300332 324014 333675 359377 364049 408489 414852 428310 438038 440113 458193 554789 643468 666525 683112 690791 707313 720088 741028 748785 789826 796576 800966 832867 851750 861044 862283 900756 926925 939560 955678 965636 9740...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 3ms
memory: 13392kb
input:
425 753881706 405729786 890889563 29736246 598281970 208352067 357783003 663497023 178397034 4832890 562140755 510307001 354540290 538848551 436879256 86659033 42928516 24145404 749159097 118423198 506851985 204895765 719719998 726244368 991372008 681703480 799303017 657138050 88278945 417801236 260...
output:
2
result:
wrong answer 3rd lines differ - expected: '13', found: '2'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Time Limit Exceeded
Test #65:
score: 0
Time Limit Exceeded
input:
99308 491693640 24020487 317364185 726230755 737284540 951143270 709116045 641023337 360629062 964879440 47884022 532494780 803629825 635450854 688041998 573937055 113198481 191311841 929603572 636688 598629732 895342035 396521271 619919754 716589045 657789547 373121546 866402108 609316614 60046511 ...
output:
51 94 64 156 16 98 197 6 96 71 108 27 86 73 71 120 75 128 223 135 90 203 40 132 71 30 33 16 101 152 61 48 68 65 140 109 59 63 182 78 68 43 22 126 8 69 62 122 167 98 104 39 99 94 15 88 26 52 138 73 10 128 61 93 52 55 99 103 88 101 53 118 44 189 103 59 30 193 70 39 52 37 91 160 95 63 105 33 41 72 14 1...
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #86:
score: 0
Time Limit Exceeded
input:
23881 605288257 422163932 155875880 339929874 76049859 196344969 958160745 767945284 469191956 997116006 387749577 15911341 920437918 367576975 800789357 351557615 283723284 369507452 841548133 643412903 309731505 256549694 370065644 699518122 559017597 347646657 469353381 575240521 501893001 454519...
output:
36 36 17 36 36 36 17 36 17 36 36 36 36 17 36 36 36 36 36 17 36 36 36 36 17 17 36 17 36 36 36 36 36 17 36 36 36 36 17 36 36 36 17 36 17 17 36 36 36 36 36 36 17 17 36 36 36 17 36 17 36 17 17 36 36 36 36 17 36 36 17 36 17 17 36 36 36 36 17 17 36 36 36 36 36 36 17 36 36 17 36 36 36 36 36 36 17 17 17 36 ...
result:
Subtask #6:
score: 0
Skipped
Dependency #4:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%