QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#542313 | #4563. Radio Towers | Wansur | 14 | 79ms | 16132kb | C++23 | 1.4kb | 2024-09-01 00:14:11 | 2024-09-01 00:14:11 |
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++;
if(l == r) return 1;
return max(0, pref[r-1] - pref[l]) + (a[l] < a[l + 1]) + (a[r] < a[r - 1]);
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 27ms
memory: 12792kb
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 2 1 1 2 1 1 1 1 1 1 2 1 1 2 1 1 2 1 1 1 1 2 2 1 1 2 1 2 1 2 2 1 1 1 2 1 1 1 1 1 1 1 2 2 2 1 2 2 1 2 2 1 1 1 1 1 2 1 2 1 1 1 1 2 1 1 2 1 2 1 2 1 1 2 2 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 2 2 2 1 1 1 2 1 1 1 2 1 1 2 1 1 1 2 2 1 2 1 1 2 1 1 1 2 1 1 2 1 1 1 1 1 1 2 ...
result:
wrong answer 4th lines differ - expected: '1', found: '2'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 8152kb
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: 14
Accepted
Test #65:
score: 14
Accepted
time: 63ms
memory: 14932kb
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:
11903 4770 14278 13956 571 9308 4389 9 22097 16784 26037 2813 8487 16602 2029 6158 17236 29707 19863 12083 20816 18090 4195 11612 4623 6658 7660 624 9839 13012 14475 11799 14795 6365 7308 5981 13614 14208 15922 17325 6020 10291 1819 29076 3117 6638 5810 28747 14944 9541 5498 1015 5001 20938 305 1993...
result:
ok 76385 lines
Test #66:
score: 14
Accepted
time: 67ms
memory: 14744kb
input:
100000 646527498 970130195 879656883 854139882 920539450 14492099 70829155 825526447 519236533 385324961 763550841 616593724 202907362 504717767 861551686 907280958 806537098 75704450 554965405 422432432 940208667 752899470 775720977 966726690 961764576 993069149 823583546 69522676 360505418 7633091...
output:
14639 9186 584 818 3164 16444 1579 16458 6571 5493 20925 3038 3459 7677 14998 8753 2530 12026 13859 985 3177 296 398 6246 6210 6153 7709 24258 1152 3748 7952 8080 13438 5107 1161 4986 23542 15941 18037 791 15601 8274 3031 13339 8920 8559 11180 24013 394 8673 4017 6704 6973 210 2085 8072 3422 6896 10...
result:
ok 100002 lines
Test #67:
score: 14
Accepted
time: 61ms
memory: 15248kb
input:
100000 799666095 11912869 1942326 329008647 676518434 731915773 50963049 775935498 336708769 698841857 979426630 497121885 413375659 771207486 690312572 933493505 987882987 160504698 336117631 191934672 178953077 95891702 137046482 542428354 425646854 622674091 727455806 150971684 875220551 94422593...
output:
3359 5788 2636 4749 12929 3462 9867 19742 27431 10049 6507 21413 26395 16171 1065 1099 6059 3852 827 8338 4447 19422 6687 18554 12713 17167 17551 6782 6320 12234 14788 9130 5326 19419 3788 8 4527 7191 2972 21849 17183 18614 8536 21210 4177 6455 5606 163 18117 7891 14769 7953 1074 4478 11977 29196 40...
result:
ok 100002 lines
Test #68:
score: 14
Accepted
time: 69ms
memory: 14556kb
input:
100000 309383765 818406090 14295145 629135702 209715251 509716889 12520088 913509863 261355145 755723016 134249674 908312702 67849537 765830435 242732056 593027397 386060391 727871977 280196624 593068179 108402646 788956280 297991891 717564506 119204481 557237512 343638543 799142578 267285209 810194...
output:
23097 5447 23783 27586 952 21564 3870 8703 21117 7700 11000 20983 38022 2663 941 11454 2759 11174 36632 8509 16858 40362 25309 12070 32624 30796 9202 7175 11966 11519 16231 6793 36568 6656 25316 20825 14867 22408 3890 4120 1635 13839 29293 20761 28612 2624 9766 31836 8423 11943 11214 14008 661 8133 ...
result:
ok 100002 lines
Test #69:
score: 14
Accepted
time: 63ms
memory: 15168kb
input:
100000 398604064 517084515 403316469 941093925 341076538 763446081 355078186 592439416 478732289 646978211 411743599 905272211 443935337 593019442 240172880 860046653 35947342 589508481 340756803 701412642 475907286 706217099 208187382 909958202 390508631 817202038 114304432 775409240 89780581 53218...
output:
24400 36714 13886 14509 36820 1421 7548 27671 1349 26896 5653 25203 6164 5360 21403 33193 8148 7314 39871 8396 17198 6121 1871 1497 4763 30054 5495 31727 24694 45309 25900 28269 6858 9003 2063 4238 44756 22939 13667 25304 24777 19243 2781 36090 7651 12367 47033 6413 11981 4430 7511 25676 32483 36198...
result:
ok 100002 lines
Test #70:
score: 14
Accepted
time: 70ms
memory: 15284kb
input:
100000 470436767 754487792 461866345 963898735 349595303 728616335 250549334 578810355 347325118 804024766 15413294 787037528 105324976 872668363 473184954 707188829 464977606 782556528 256065321 752907482 412827734 758149764 362598737 510432812 220636665 831053655 189976212 708640841 59667440 87439...
output:
4031 19471 10612 11305 29772 29874 21670 2464 5310 25620 24369 6447 795 10520 18039 1110 11300 7418 19857 3817 7976 14218 18688 45775 31258 24208 13949 1287 11237 32270 34202 9525 38736 11963 21324 21122 13715 45274 28148 26076 726 24521 11067 20365 5491 7039 20594 14715 4222 15081 3768 12930 11824 ...
result:
ok 100002 lines
Test #71:
score: 14
Accepted
time: 79ms
memory: 15384kb
input:
100000 412173417 598390408 450506026 862926714 62758084 584835820 312278703 842539009 241894641 534565458 27030476 943943695 471359870 991029867 307671828 975813712 466428149 865400208 101594411 879257618 112546625 917139766 242222832 744966595 51074647 579442498 239653108 584603561 477338553 655568...
output:
33924 11012 17217 5652 35774 19773 7167 16147 4921 22378 2886 6381 20729 25984 37105 33701 12765 15814 31567 4523 3853 2591 5038 24440 15123 29860 5543 28365 21666 6416 7901 16121 5444 18700 17557 8004 9915 26519 5987 605 7786 4804 4099 16672 20783 5924 44630 21907 44651 18917 6041 5328 4338 15527 3...
result:
ok 100002 lines
Test #72:
score: 14
Accepted
time: 38ms
memory: 12632kb
input:
100000 2879 32457 32800 34124 37088 65871 67630 69007 70609 76863 96036 96369 96565 105168 106207 119568 120684 131675 139246 156582 157087 161216 175779 185692 192424 252496 261161 268435 272206 274575 290650 292159 302124 302145 323135 347536 353475 358692 362164 370878 382914 383697 387884 395290...
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 #73:
score: 14
Accepted
time: 51ms
memory: 12340kb
input:
100000 999980337 999975418 999972304 999917615 999913600 999911365 999900298 999895568 999873059 999868465 999863826 999863630 999862039 999833583 999826253 999820741 999808163 999794394 999788715 999775323 999771102 999765847 999750783 999746445 999710318 999708459 999707434 999695764 999679223 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 #74:
score: 14
Accepted
time: 51ms
memory: 13696kb
input:
100000 2635 21487 31880 36169 36537 36733 50286 55501 101667 105396 109937 125176 130431 131349 131526 133585 145149 148230 148497 181038 199372 208320 214709 228385 229354 234058 246813 259715 259821 304855 307878 319123 322813 329890 338817 340380 349808 359373 361892 364235 365371 367741 392751 4...
output:
1 1 5 1 1 4 4 2 2 5 4 2 4 2 1 5 5 5 4 2 1 1 1 1 1 2 4 3 4 4 3 2 1 5 1 5 5 1 2 4 5 2 5 5 3 2 2 2 5 4 2 5 5 5 5 1 1 2 1 1 4 4 5 5 4 5 1 5 3 2 4 1 1 5 1 2 3 2 1 1 5 5 2 2 5 1 1 1 2 4 4 5 1 1 4 1 2 2 3 5 1 4 1 2 5 4 1 2 1 1 5 1 4 5 1 1 4 4 4 1 4 3 1 2 5 1 5 2 5 2 1 4 2 1 3 5 1 1 2 2 1 1 5 5 3 1 3 5 4 2 ...
result:
ok 100002 lines
Test #75:
score: 14
Accepted
time: 48ms
memory: 13708kb
input:
100000 999998388 999992472 999983027 999964773 999963279 999951283 999950880 999934408 999924387 999916418 999904684 999903982 999903323 999902932 999901848 999890455 999861126 999846824 999842850 999832617 999827692 999823954 999823038 999821892 999814773 999791390 999779861 999755956 999748895 999...
output:
2 4 2 4 3 2 5 2 2 2 2 1 4 2 3 3 4 1 2 2 1 2 2 1 3 1 1 3 1 3 3 3 1 3 2 1 2 1 5 2 3 1 2 3 2 2 1 1 3 4 1 1 1 1 2 2 5 1 2 4 2 1 1 5 3 1 2 1 5 2 1 1 4 1 1 2 1 3 3 4 3 5 1 2 1 2 1 1 2 1 1 2 1 2 2 2 1 2 3 2 2 1 4 1 1 1 2 1 2 1 3 4 3 4 1 1 1 3 2 2 2 3 2 2 4 1 1 2 2 3 1 1 1 1 1 4 2 2 3 1 1 3 1 3 5 3 1 1 2 4 ...
result:
ok 100002 lines
Test #76:
score: 14
Accepted
time: 40ms
memory: 14956kb
input:
100000 993008519 146022225 604155615 718738203 494270163 652193137 726796672 94792684 820864876 549569362 829507440 678929032 370307391 344030005 159841431 334544886 937946370 808171575 982936137 406172084 606958454 37019021 4928645 19688703 431277735 368642501 122957106 319157770 412765992 11198976...
output:
11803
result:
ok 3 lines
Test #77:
score: 14
Accepted
time: 46ms
memory: 14592kb
input:
100000 40182145 534750963 47219441 875390747 81526264 760417678 338532233 735498264 324045878 867847994 59843568 773887600 159787753 815005992 380202117 994057104 420819027 751621209 431455690 874518582 286468788 746915239 108591545 609413028 129180541 684472848 170951027 628699282 133169234 5876429...
output:
10641
result:
ok 3 lines
Test #78:
score: 14
Accepted
time: 42ms
memory: 15692kb
input:
100000 275422663 623971262 359872300 719293364 255135323 541992266 440822587 869808644 499149139 763707030 354974961 726924800 330201357 680217772 405944508 793791040 210835281 508081687 259941660 743715189 158261318 948118520 78257478 668842593 103644266 931463910 338599866 777663876 422872806 7486...
output:
3918
result:
ok 3 lines
Test #79:
score: 14
Accepted
time: 14ms
memory: 14140kb
input:
100000 999988156 999976131 999968026 999947275 999945597 999933785 999930172 999920289 999917585 999912234 999908854 999897793 999885917 999875073 999869174 999855731 999844433 999811617 999807251 999800921 999792585 999786180 999781483 999760080 999750045 999744093 999742092 999740171 999733488 999...
output:
1
result:
ok 3 lines
Test #80:
score: 14
Accepted
time: 15ms
memory: 12744kb
input:
100000 13698 28310 35130 49038 53306 57086 63036 75561 76672 81572 87405 101823 116392 121336 131981 152687 154046 161564 166916 167077 175074 181353 215368 216356 242236 282273 302168 302245 315363 328425 331460 337542 344358 346156 346268 349988 364543 398098 398173 417443 425254 429806 483805 495...
output:
3
result:
ok 3 lines
Test #81:
score: 14
Accepted
time: 39ms
memory: 13928kb
input:
100000 686070451 896400233 415977400 557145966 569104546 729711476 7517469 585286333 654728559 526059886 664580363 44964974 822423618 924237671 253134105 907248874 842926901 490665647 968126707 843652090 577413524 822838296 701325974 418582281 682668062 910983736 688209040 48680293 467513665 6473215...
output:
33289
result:
ok 3 lines
Test #82:
score: 14
Accepted
time: 46ms
memory: 16132kb
input:
100000 324786527 811070346 27863928 812278519 469886012 725613704 314110706 938011015 447486290 790851139 225255488 588777115 157708439 967669178 122826315 605497395 442130539 901574836 449101384 630033703 363487572 640039974 495641990 646810950 101835263 504819182 341085568 818338550 309812680 8340...
output:
50000
result:
ok 3 lines
Test #83:
score: 14
Accepted
time: 46ms
memory: 15092kb
input:
100000 328751617 872776434 193896091 937579789 403324609 884873962 19096263 546885897 299955068 810378130 266985913 855008900 113957467 674955114 367808805 824606229 36085456 748004114 360544279 875870329 490814410 550516261 480140569 978076458 371373042 557323008 337625884 791543744 389714119 82617...
output:
49998
result:
ok 3 lines
Test #84:
score: 14
Accepted
time: 15ms
memory: 13748kb
input:
100000 999994414 999989068 999983169 999973305 999956998 999952735 999935815 999932727 999921388 999912247 999910668 999892587 999886472 999886197 999877300 999875077 999873271 999862506 999847958 999843765 999831825 999818755 999813197 999811659 999808140 999800414 999789177 999788823 999783126 999...
output:
1
result:
ok 3 lines
Test #85:
score: 14
Accepted
time: 18ms
memory: 13808kb
input:
100000 552 1167 1507 1559 5688 6188 8616 38613 47871 73234 76958 93583 142300 154838 156445 162479 168262 172236 175115 183892 187208 211463 265659 275302 279294 291311 332477 340758 376960 387576 395567 397517 415963 417398 449245 452439 456342 465878 468169 475771 481256 491236 503318 507666 52887...
output:
5
result:
ok 3 lines
Subtask #5:
score: 0
Wrong Answer
Test #86:
score: 0
Wrong Answer
time: 14ms
memory: 13012kb
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
Wrong Answer
Dependency #4:
100%
Accepted
Test #97:
score: 0
Wrong Answer
time: 56ms
memory: 14880kb
input:
88768 238644804 620122421 789364401 899010695 885388612 437964772 845379533 657562749 773925456 625793781 916240972 291506550 379611161 905077982 629848170 530056471 520438258 806293637 326792996 785404568 74285074 565304193 846963319 63529729 804909008 212070492 69936548 656129389 408708069 3070450...
output:
8349 21427 5662 21827 26907 2291 23916 10524 24336 18016 129 13455 9770 21976 10777 10481 6181 23042 1919 4552 25920 6777 20509 14798 6559 14190 24784 18071 733 6200 19472 8746 7040 2033 7226 713 876 3519 10084 13229 8251 3019 18152 2596 2309 11129 27487 5329 10158 5747 2767 23134 9529 16660 18864 7...
result:
wrong answer 3rd lines differ - expected: '7293', found: '8349'
Subtask #7:
score: 0
Skipped
Dependency #1:
0%