QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#536762 | #4563. Radio Towers | Wansur# | 0 | 54ms | 14168kb | C++23 | 1.4kb | 2024-08-29 16:27:27 | 2024-08-29 16:27:27 |
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 pref[maxn];
int n, d;
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))]);
}
} vector<int> ord;
for(int i=1;i<=n;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);
pref[i] = 1;
}
}
for(int i=1;i<=n;i++){
pref[i] += pref[i-1];
}
}
int max_towers(int l, int r, int D) {
d = D;
l++, r++;
return pref[r] - pref[l-1];
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 31ms
memory: 12760kb
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:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 3rd lines differ - expected: '1', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 7912kb
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:
16
result:
wrong answer 3rd lines differ - expected: '13', found: '16'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #65:
score: 0
Wrong Answer
time: 54ms
memory: 14168kb
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:
11902 4770 14278 13956 570 9308 4389 9 22097 16784 26037 2813 8487 16601 2029 6158 17236 29707 19863 12083 20815 18090 4195 11612 4623 6657 7660 623 9837 13012 14474 11799 14795 6364 7308 5981 13613 14208 15922 17325 6019 10291 1819 29076 3116 6638 5810 28745 14944 9540 5498 1014 5001 20938 304 1993...
result:
wrong answer 3rd lines differ - expected: '11903', found: '11902'
Subtask #5:
score: 0
Wrong Answer
Test #86:
score: 0
Wrong Answer
time: 18ms
memory: 12744kb
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:
8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 8004 ...
result:
wrong answer 3rd lines differ - expected: '7197', found: '8004'
Subtask #6:
score: 0
Skipped
Dependency #4:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%