QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#542387 | #4563. Radio Towers | Wansur | 17 | 62ms | 13820kb | C++23 | 1.4kb | 2024-09-01 01:01:55 | 2024-09-01 01:01:56 |
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];
vector<int> ord;
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++){
dp[i] = 2e9;
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))]);
}
}
stack<int> s;
for(int i=1;i<=n;i++){
while(s.size() && a[s.top()] > a[i]){
s.pop();
}
if(s.size()){
dp[i] = get(s.top() + 1, i - 1);
}
s.push(i);
}
while(s.size()) s.pop();
for(int i=n;i;i--){
while(s.size() && a[s.top()] > a[i]){
s.pop();
}
if(s.size()){
dp[i] = min(dp[i], get(i + 1, s.top() - 1));
}
s.push(i);
if(dp[i] != 2e9){
ord.push_back(dp[i] - a[i]);
}
}
sort(ord.begin(), ord.end());
}
int max_towers(int l, int r, int D) {
return (int)ord.size() - (int)(lower_bound(ord.begin(), ord.end(), D) - ord.begin()) + 1;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 34ms
memory: 11556kb
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:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
wrong answer 3rd lines differ - expected: '1', found: '2'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 8156kb
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:
131
result:
wrong answer 3rd lines differ - expected: '13', found: '131'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #65:
score: 0
Wrong Answer
time: 39ms
memory: 12688kb
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:
33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 33010 ...
result:
wrong answer 3rd lines differ - expected: '11903', found: '33010'
Subtask #5:
score: 17
Accepted
Test #86:
score: 17
Accepted
time: 12ms
memory: 12468kb
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:
7197 7063 150 5030 5227 7333 1778 6675 2012 5921 4878 7477 4598 2769 5360 6465 7660 7234 7794 2760 6321 7056 7302 4749 464 2029 5650 1973 6227 4900 4966 4990 3142 785 5818 3005 7705 6967 1940 5880 7201 4752 1278 6554 2951 894 6601 7019 7236 6076 5182 6579 2343 2070 4337 5744 4437 2262 6686 1739 7756...
result:
ok 31567 lines
Test #87:
score: 17
Accepted
time: 58ms
memory: 12560kb
input:
100000 187962236 252322706 659740540 756184857 615615021 870954164 997894181 924184575 178246679 206117936 948374169 611376809 940125697 583402158 621243496 179806768 420420048 261580744 495350370 179501503 624736464 865025098 132756697 396891347 254854635 384499314 232013282 699329403 718265326 972...
output:
21501 24099 33073 16936 24145 8440 674 23350 29618 2899 7659 19499 19027 10215 4083 14518 30601 23009 17970 7096 15472 32634 26673 29553 6232 11457 690 8753 7786 4078 28404 25386 28535 1752 5912 16456 18098 25382 30618 28242 30215 30920 19228 20981 27023 18696 16047 19091 7953 9832 13542 4224 26991 ...
result:
ok 100002 lines
Test #88:
score: 17
Accepted
time: 51ms
memory: 12364kb
input:
100000 195876641 146621733 341834495 380796725 369334549 293410542 978028075 874593626 703011075 519634832 164249958 637129162 298077642 409700388 597488029 208278772 746990129 51413696 131278404 949003744 715997226 208017329 494082201 972593011 718736913 14104256 281109734 780778410 380464107 29853...
output:
31327 32678 5845 12353 3257 8926 13111 9562 10067 19324 255 7803 6244 5462 17193 33299 5823 24299 31456 20379 13299 17670 10250 31047 750 28337 5058 5037 31225 2578 18079 32308 15960 21734 23722 17448 3403 22865 12869 22981 12521 27550 32677 8772 16024 27145 32107 20420 31630 25199 583 30494 13145 2...
result:
ok 100002 lines
Test #89:
score: 17
Accepted
time: 60ms
memory: 13608kb
input:
100000 140151127 703171223 64650609 807179656 91579199 616439566 262279532 635385641 182204773 746966272 29134735 694384584 151383885 835424004 374370699 839210095 26199233 802967114 424348660 929961627 334908843 613933030 264472963 967927306 374534013 795616963 181399017 942772713 325557168 6356971...
output:
16852 44989 5073 188 18334 719 37773 31991 27369 49758 2886 37462 2269 14671 36297 47833 45768 45948 44197 36763 13579 37257 34232 22326 19121 4483 3193 9572 44327 43476 37410 4641 9134 21884 17460 39750 31826 13138 6713 29509 28834 48569 47845 14636 42288 209 9318 7431 45730 16465 5906 40699 39638 ...
result:
ok 100002 lines
Test #90:
score: 17
Accepted
time: 62ms
memory: 13612kb
input:
100000 229371426 615845385 8395463 725670138 253945139 837481603 267122821 564928938 88384991 615119435 233045729 736737408 9623699 705904592 292693606 920163778 297466268 725313668 361252589 813252985 350864743 741659990 170849476 539562600 432839207 511464025 99353592 875179636 297454089 687124695...
output:
17581 24948 38391 14419 27799 4569 38668 35697 26067 49978 42190 1235 1655 28211 22625 47715 40160 39008 37550 19341 5003 109 10527 40699 48346 4305 5676 8370 23348 27672 31587 48842 49999 46869 20992 43858 6386 35113 50 46394 49096 24013 33036 49696 44127 30556 26524 3723 36254 9349 12089 2510 3087...
result:
ok 100002 lines
Test #91:
score: 17
Accepted
time: 45ms
memory: 13236kb
input:
100000 487111066 855860485 99041551 892763368 90402565 506637676 222215611 835773505 321823015 869201207 89953137 536799062 104579533 834586895 472040129 763002761 152483347 634595719 449887741 956583186 34700464 521025155 55345113 944384213 127641496 513194723 356649230 967880428 337980827 91463839...
output:
942 45725 29253 32000 34983 3056 10934 34915 6732 11677 1908 652 47087 1198 27913 18121 7533 3821 24817 31833 5715 2456 36255 41755 48827 46825 46456 9695 562 7920 24435 19004 5205 24363 3456 48946 23953 49466 31719 39841 12272 16871 42212 19612 38959 9101 5563 12587 43949 48475 41360 6428 41967 184...
result:
ok 100002 lines
Test #92:
score: 17
Accepted
time: 58ms
memory: 12656kb
input:
100000 27073748 576331364 400237255 795460519 71014022 637435072 214575137 823870913 216504420 807569134 433278403 608674530 363485760 723516242 157786468 990284424 191375275 730792204 290439949 971661182 370244883 986406055 345467763 738556373 233197961 953353962 129769517 642436238 381534949 97463...
output:
15228 45987 5889 540 24979 14594 39331 30269 9981 22404 3267 11420 12707 42431 49834 35779 22037 20640 28981 41713 13306 2152 44699 25014 49999 49722 28703 25852 31644 27995 42377 43981 46325 34863 25315 25298 48064 12187 614 35850 45155 47254 21988 7289 5643 47552 48834 14785 10748 44858 26283 2402...
result:
ok 100002 lines
Test #93:
score: 17
Accepted
time: 43ms
memory: 13456kb
input:
100000 14044 31568 48921 51214 59358 71379 100023 115598 139483 155653 157116 163984 169449 181325 188904 191112 194401 200495 208085 244825 258317 269389 271415 278442 294904 302861 331145 358689 365346 371514 371674 420312 426358 426926 439486 447109 449034 452747 459208 464379 471543 477242 48520...
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:
ok 100002 lines
Test #94:
score: 17
Accepted
time: 42ms
memory: 13820kb
input:
100000 999997134 999971880 999971447 999963682 999958496 999954233 999941005 999934956 999913043 999912124 999899751 999895915 999889723 999865869 999850495 999849430 999843930 999825051 999812617 999790616 999785641 999771255 999768902 999766470 999753769 999744896 999726315 999707943 999707638 999...
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:
ok 100002 lines
Test #95:
score: 17
Accepted
time: 41ms
memory: 13636kb
input:
100000 10308 12726 14970 29067 32105 43123 49977 68697 88015 88028 126474 130169 135685 137521 160062 169353 177310 194965 211656 230278 234919 235394 248590 252495 255260 261674 277375 302750 310249 323236 330372 331411 353695 359830 374529 382948 412643 433170 449860 454473 473256 476229 477424 48...
output:
5 3 5 5 1 5 1 2 1 3 3 5 3 5 5 5 5 2 3 5 5 1 5 1 1 2 3 5 5 2 2 5 5 1 1 4 1 1 1 5 5 1 1 1 1 5 5 3 5 5 1 1 3 5 3 5 5 3 4 4 5 1 2 3 1 4 5 3 5 3 5 5 1 4 2 3 5 5 1 3 1 3 5 5 4 1 5 2 5 1 1 3 5 5 1 3 1 5 5 5 5 3 5 1 5 2 1 4 5 4 1 5 4 1 5 3 2 5 1 5 2 5 5 2 5 1 2 5 1 3 5 2 3 1 4 1 3 5 4 4 1 2 5 3 5 3 2 5 1 1 ...
result:
ok 100002 lines
Test #96:
score: 17
Accepted
time: 45ms
memory: 13440kb
input:
100000 999999375 999993451 999991946 999986204 999984712 999978443 999965310 999963490 999950472 999950215 999935622 999934052 999920801 999884366 999878792 999871703 999841904 999839499 999835391 999831297 999828717 999815901 999773795 999769518 999747787 999736911 999729803 999726952 999716990 999...
output:
3 1 3 5 3 3 1 4 5 3 3 3 3 1 3 3 3 3 1 4 1 1 3 3 1 2 4 1 3 3 1 3 3 2 4 3 1 3 3 2 2 3 3 3 3 1 5 3 3 5 1 3 1 3 3 3 4 3 3 5 3 3 4 3 1 3 3 3 5 3 3 5 5 3 5 3 2 3 5 3 5 5 3 4 3 3 5 3 3 3 3 3 5 3 1 3 3 1 3 3 3 3 3 5 3 4 3 4 3 1 3 1 3 5 3 5 3 3 1 3 2 3 3 5 3 3 4 4 3 3 3 3 5 3 4 3 1 3 1 3 3 1 1 3 5 3 3 3 3 3 ...
result:
ok 100002 lines
Subtask #6:
score: 0
Skipped
Dependency #4:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%