QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#152919#149. PeruAbdelmagedNour#49 34ms12992kbC++201.0kb2023-08-29 00:31:452024-09-10 16:43:54

Judging History

你现在查看的是最新测评结果

  • [2024-09-10 16:43:54]
  • 管理员手动重测本题所有提交记录
  • 测评结果:49
  • 用时:34ms
  • 内存:12992kb
  • [2024-07-04 01:52:12]
  • 评测
  • [2023-08-29 00:31:45]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
//#include "grader.cpp"
#include "peru.h"
typedef long long ll;
const int N=2500005,mod=(1e9)+7;
ll dp[N];
bitset<N>in_queue;
int solve(int n, int k, int* v){
    deque<int>dq;
    v--;
    priority_queue<pair<ll,pair<int,int>>,vector<pair<ll,pair<int,int>>>,greater<pair<ll,pair<int,int>>>>pq;
    for(int i=1;i<=n;i++){
        while(!dq.empty()&&dq.front()<i-k)in_queue[dq[0]]=0,dq.pop_front();
        while(!dq.empty()&&v[dq.back()]<=v[i])in_queue[dq.back()]=0,dq.pop_back();
        if(!dq.empty())pq.push({dp[dq.back()]+v[i],{dq.back(),i}});
        dq.push_back(i);
        in_queue[i]=1;
        while(!pq.empty()&&(!in_queue[pq.top().second.first]||!in_queue[pq.top().second.second]))pq.pop();
        dp[i]=LLONG_MAX;
        if(!pq.empty())dp[i]=pq.top().first;
        dp[i]=min(dp[i],dp[max(i-k,0)]+v[dq.front()]);
    }
    long long res=0;
    for(int i=1;i<=n;i++)res=(res*23+dp[i])%mod;
    return res;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 18
Accepted

Test #1:

score: 18
Accepted
time: 1ms
memory: 5816kb

input:

2000 170
1054018657 1037445664 1011691297 1009972317 1006506677 1002579733 999792775 999477541 975467893 970302369 968173111 957735623 953086083 938540451 932313113 930563895 924682633 917831575 913506401 908739591 905368525 899452913 894354220 890127447 885923007 583391543 880642788 878397752 87822...

output:

559335223

result:

ok single line: '559335223'

Test #2:

score: 18
Accepted
time: 0ms
memory: 7812kb

input:

2000 100
1019222751 1012312953 1005125581 978875481 967275037 967176717 965763637 960999157 957233281 956958729 953471924 942217905 936256081 925906257 922808341 918616993 918132100 915435367 911342035 909313549 902957201 902119531 900836861 99996937 892982026 884892282 884816596 884102145 883049077...

output:

818524087

result:

ok single line: '818524087'

Test #3:

score: 18
Accepted
time: 1ms
memory: 7836kb

input:

2000 20
1046023457 988320769 85389793 1819030505 635209701 362287065 747208901 958302681 957423952 1241659175 352880697 545051421 356189641 1678485313 76683576 940812217 995748541 1920846205 80556065 1358698601 483048309 1881187901 639822057 873315653 1157374529 225761262 1271878801 421346861 190846...

output:

722220390

result:

ok single line: '722220390'

Test #4:

score: 18
Accepted
time: 1ms
memory: 5840kb

input:

2000 30
1742393521 1373505943 1783981533 969067201 1868827930 1242849529 340585550 1430285741 1467707069 931245518 1652549049 1531083137 590083361 1624545751 90840583 920774329 1130261561 452306243 19102491 955643121 258267441 923161989 534143934 856297743 279514021 503065922 409174401 432771113 120...

output:

650653589

result:

ok single line: '650653589'

Test #5:

score: 18
Accepted
time: 1ms
memory: 5756kb

input:

2000 50
543424081 894641096 1339301255 1889686701 952129633 612233257 1547586801 364344001 432571137 1050383003 1137993587 685296321 666004060 67614961 585732097 121629576 1975355921 1465203126 1904792785 466104889 1562726309 1291336401 1942673537 1075318749 740251709 1038567681 1408927717 178247074...

output:

925458417

result:

ok single line: '925458417'

Test #6:

score: 18
Accepted
time: 0ms
memory: 6048kb

input:

2000 66
296941975 632767915 1762639311 958786399 1071923265 1552982561 216785941 1887579821 509308881 435656001 390210676 197780151 1301996771 1489698520 141918911 891666845 574475831 899508601 1013449051 175378801 89348801 837595313 270629113 279029177 384317601 1755443841 1235606561 1547972848 202...

output:

444646258

result:

ok single line: '444646258'

Test #7:

score: 18
Accepted
time: 1ms
memory: 7808kb

input:

2000 40
1059696721 1055166157 1044539161 1034355529 1030533441 1025978401 995197251 994572517 973608392 973353991 964014126 378408808 958025513 951750766 951037371 949770821 948486985 941198116 933949689 929560654 929512513 921764609 921307889 921167577 920417481 911390897 910270385 906125481 895972...

output:

7677983

result:

ok single line: '7677983'

Test #8:

score: 18
Accepted
time: 1ms
memory: 5852kb

input:

2000 20
1055110455 1005223324 1003873357 993841570 85534741 978021371 972929053 965514337 956876706 954140500 953747239 947700853 944007670 941645514 940364189 927465533 927214939 922020939 921390841 916331914 912757594 44655871 910441087 908052421 906270473 44773462 906022207 904501165 902742688 90...

output:

505871513

result:

ok single line: '505871513'

Test #9:

score: 18
Accepted
time: 0ms
memory: 5784kb

input:

2000 35
1022691767 1014414743 1011271745 1004244164 997794327 993850701 989771077 987749281 983716200 972060987 970129801 970068556 965852449 958249651 487933 958036353 956471803 948960379 948894321 948793357 947237281 130227931 937986316 937272479 932507293 932399201 928000385 27050453 922445926 92...

output:

211950235

result:

ok single line: '211950235'

Test #10:

score: 18
Accepted
time: 1ms
memory: 5844kb

input:

2000 50
1151914561 1495201451 1012909476 272883901 1725748641 950389217 206580001 1347030801 1931958771 1366894201 1250674465 1396662273 1905672559 1814735325 153639169 1199502271 1743930753 507709292 355904698 402770401 350650585 721029217 40258129 1743270991 207229381 435727781 1221323521 64386688...

output:

229458181

result:

ok single line: '229458181'

Test #11:

score: 18
Accepted
time: 0ms
memory: 5764kb

input:

2000 34
874023147 734709909 335190475 999498237 1581908993 272842689 1541974929 603853521 1502263105 1523850553 437313251 605618113 1252482079 1917808729 1839292253 1153661850 1768401651 970691571 296972777 1794594401 1898042336 1017506001 970010409 135942787 960588801 1817971441 1261276641 19492460...

output:

459414440

result:

ok single line: '459414440'

Test #12:

score: 18
Accepted
time: 1ms
memory: 5824kb

input:

2000 90
1945282221 581009181 63394299 627330027 1286388499 1097696131 1076306649 1761841621 1746358081 365563062 154009661 1801265786 1529431757 122058697 1381712677 411146001 1981007576 1167570621 1407588502 446110641 1597208705 414478041 1157817065 1614045761 1583648801 1166985591 1090632001 14515...

output:

198932165

result:

ok single line: '198932165'

Test #13:

score: 18
Accepted
time: 1ms
memory: 6120kb

input:

2000 101
1199509006 1918260001 1593549901 350489646 136788141 653292001 496126267 1074488441 184087969 697990641 1683056858 1992780276 705314881 403401873 771792621 236609025 1864750009 1505559241 1999940279 669693349 56972501 157466251 379727249 1265769875 347490626 1105199127 485967826 803890001 1...

output:

774419684

result:

ok single line: '774419684'

Test #14:

score: 18
Accepted
time: 1ms
memory: 5760kb

input:

2000 15
1689537321 898720501 1669337777 128316734 1978406108 1147164161 577488769 1844956801 1404644001 421025281 476255243 599476829 665843745 980993826 1894059905 152672733 330694871 1001232741 794930081 851019681 1611922961 1298969774 1580535251 1440923521 1225542751 1577310513 37273681 180104705...

output:

373845090

result:

ok single line: '373845090'

Subtask #2:

score: 31
Accepted

Test #15:

score: 31
Accepted
time: 27ms
memory: 12952kb

input:

400000 1000
1999989721 1999987224 1999984551 1999977673 1999977545 1999976801 1999975837 1999972607 1999956301 1999952801 1999942489 1999940593 1999940337 1999936353 1999936273 1999926073 1999925513 1999922980 1999918301 1999912501 1999909301 1999906125 1999902913 1999895622 1999893617 1999885490 19...

output:

677928817

result:

ok single line: '677928817'

Test #16:

score: 31
Accepted
time: 31ms
memory: 11352kb

input:

400000 800
1999974677 1999969921 1999965861 1999958493 1999958025 1999951391 1999947061 1999946921 1999944101 1999935101 1999934785 1999933729 1999933327 1999928689 1999921281 224119121 1999917457 1999914027 1999910181 1999903529 1999898241 1999890703 1999885291 1999877461 1999873851 1999865681 1999...

output:

390755425

result:

ok single line: '390755425'

Test #17:

score: 31
Accepted
time: 32ms
memory: 12312kb

input:

400000 450
1999991201 1999979985 1999975126 1999974440 1999968416 1999967617 1999961247 1999954759 1999945501 1999937001 1999936731 1999932397 1999931699 1999920033 1999919661 1999918093 1999913161 1999912681 1999901601 1999900001 1999892893 1999892117 1999892001 1999890311 1999887241 1999876001 199...

output:

365578785

result:

ok single line: '365578785'

Test #18:

score: 31
Accepted
time: 33ms
memory: 12292kb

input:

400000 500
440022081 1622703530 1063680545 1389784061 156690529 1044960001 1706989155 585548737 862752082 1938320961 1661424788 712296212 175535409 1843881991 992287026 1927314057 444990016 982477251 570841481 696788323 103688779 1719893793 425526289 963642805 497218401 1386584473 1375446512 4420463...

output:

247532529

result:

ok single line: '247532529'

Test #19:

score: 31
Accepted
time: 26ms
memory: 11440kb

input:

400000 650
1900456001 1904270001 68077633 123179649 797555089 498376481 1094348785 713705836 1795564891 1261056841 1480102753 285424785 821999875 1335202369 1875343841 315992801 1120959281 1385842626 768509251 795094479 713022001 510269921 1887870223 597184690 323561921 1669562206 724196281 10102726...

output:

183988362

result:

ok single line: '183988362'

Test #20:

score: 31
Accepted
time: 30ms
memory: 12992kb

input:

400000 1300
1806028931 1438649732 543808975 161507631 551736143 1408338501 1873943061 840318824 195546633 1044113181 850075401 1673847734 225047461 1320104618 1773423867 1711295841 1335980313 1283139634 192576486 475090593 593545985 1647896541 1373520957 565249356 10545726 840640517 330715201 193050...

output:

49006593

result:

ok single line: '49006593'

Test #21:

score: 31
Accepted
time: 28ms
memory: 11980kb

input:

400000 900
1999995133 1999993797 1999991878 1999991783 1999983777 1999981781 1999977249 1999975153 1999972581 1999971251 1999965201 1999959297 1999957761 1999951841 1999951305 1999949915 1999936321 1999935201 1999932953 1999926881 1999911777 1999906173 1999905351 1999898321 1999897971 1999878619 199...

output:

231789327

result:

ok single line: '231789327'

Test #22:

score: 31
Accepted
time: 31ms
memory: 11756kb

input:

400000 1900
1999999041 1999996876 1999992065 1999991523 1999989941 1999984597 1999982801 1999980755 1999966721 1999961515 1999960821 1999959601 1999950395 1999946001 1999938995 1999938101 1999921601 1999921165 1999919839 1999915521 1999914409 1999906229 1999890526 1999888705 1999883521 1999882501 19...

output:

497399601

result:

ok single line: '497399601'

Test #23:

score: 31
Accepted
time: 30ms
memory: 11904kb

input:

400000 2300
1999996581 1999995301 1999994497 1999993809 1999993585 1999991051 1999990101 1999974971 1999972961 1999969105 1999960211 1999958689 1999949601 1999946401 1999945193 1999944481 1999928561 1999924311 1999915181 1999911897 1999902969 1999894945 1999893836 1999893665 1999893593 1999888701 19...

output:

904238590

result:

ok single line: '904238590'

Test #24:

score: 31
Accepted
time: 34ms
memory: 11392kb

input:

400000 900
1999999209 1999997333 1999996361 1999981685 1999979785 1999978679 1999977457 1999977121 1999970433 1999969027 1999959781 1999953985 1999951531 1999948321 1999933341 1999931141 1999927851 1999924505 1999914471 1999913636 1999909241 1999906601 1999902545 1999898801 1999897509 1999892161 199...

output:

572758569

result:

ok single line: '572758569'

Test #25:

score: 31
Accepted
time: 29ms
memory: 11548kb

input:

400000 850
1999995169 1999986432 1999978001 1999972661 1999966449 1999951553 1999944641 1999943481 1999920201 1999912329 1999905561 1999898751 1999894529 1999887501 1999882981 1999881761 1999880561 1999876201 1999875521 1999873281 1999872061 1999867569 1999863026 1999860203 1999859737 1999858441 199...

output:

749891606

result:

ok single line: '749891606'

Test #26:

score: 31
Accepted
time: 27ms
memory: 12352kb

input:

400000 500
1999994079 1999991301 1999990365 1999984001 1999978345 1999967233 1999958609 1999941501 1999932441 1999923983 1999921751 1999917821 1999905901 1999901391 1999899490 1999893116 1999879201 1999876505 1999868429 1999862321 1999858226 1999834841 1999829601 1999826008 1999825618 1999823891 199...

output:

687211066

result:

ok single line: '687211066'

Test #27:

score: 31
Accepted
time: 27ms
memory: 11164kb

input:

400000 1300
1999989511 1999988401 1999988401 1999988351 1999986866 1999979611 1999972633 1999963421 1999956737 1999942001 1999937217 170230821 1999925249 1999920941 1999920001 1999917196 1999915631 1999915461 1999905799 1999902601 1999896001 1999893471 1999889001 1999879881 1999875983 1999875667 199...

output:

684392658

result:

ok single line: '684392658'

Test #28:

score: 31
Accepted
time: 32ms
memory: 12488kb

input:

400000 2000
1999994801 1999988327 1999988311 1999986321 1999985121 1999984479 1999973259 1999961801 1999961521 1999961226 1999953121 1999952514 1999939709 1999929471 1999928029 1999917835 1999906521 1999902071 1999895470 1999892585 1999892221 1999887585 1999885755 1999883276 1999880001 1999877351 19...

output:

964235081

result:

ok single line: '964235081'

Test #29:

score: 31
Accepted
time: 31ms
memory: 11396kb

input:

400000 5432
1999996581 1999995901 1999992577 1999981745 1999976601 1999959721 1999950491 1999949378 1999942369 1999934721 1999930881 1999923667 1999916358 1865412390 1999915071 1999909921 1999903233 1999899129 1999896798 1999893721 1999888832 1999882981 1999882714 1999880276 1999877121 1999874675 19...

output:

569690546

result:

ok single line: '569690546'

Test #30:

score: 31
Accepted
time: 32ms
memory: 12784kb

input:

400000 999
1999996037 1999994441 1999990032 1999989871 1999976071 1999964221 1999964099 1999960485 1999950961 1999932895 1999932325 1999904129 1999902397 1999895301 1999891089 1999880334 1999880087 1999873496 1999871201 1999868371 1508345140 1999866161 1999864931 1999864705 1999859785 1999858665 199...

output:

607828837

result:

ok single line: '607828837'

Test #31:

score: 31
Accepted
time: 27ms
memory: 12924kb

input:

400000 345
1999990873 1999987441 1999983927 1999981676 1999973121 1999969040 1999968257 1999968217 1999960001 1999946701 1999938921 1999922313 1999897691 1999889297 1999885401 1999877121 1999870817 1999867493 1999862717 1999858342 1999849094 1999845767 1999843751 1999842234 1999841801 1999838041 199...

output:

466507090

result:

ok single line: '466507090'

Test #32:

score: 31
Accepted
time: 29ms
memory: 11824kb

input:

400000 2900
1999983696 1999973121 1999971985 1999968209 1999950145 1999946753 1999943653 1999943605 1999942789 1999941233 1999936601 1999933575 1999932801 1999923657 1999921641 1999910617 1999909561 1999907841 1999901081 1999886105 1999882319 1999878081 1999866813 1999863921 1999862583 1999847745 19...

output:

578913981

result:

ok single line: '578913981'

Test #33:

score: 31
Accepted
time: 27ms
memory: 12196kb

input:

400000 300
1999999649 1999995361 1999994181 1999992801 1999988565 1999982003 1999969341 1999967461 1999960321 1999955781 1999954777 1999951641 1999946595 1999935030 1999920237 1999918067 1999914601 1999908081 1999906448 1999905281 1999904869 1999899361 1999896721 1999891466 1999884457 1999881401 199...

output:

617356184

result:

ok single line: '617356184'

Subtask #3:

score: 0
Time Limit Exceeded

Test #34:

score: 0
Time Limit Exceeded

input:

2500000 2000
1073315871 1073250349 1072791751 1072104046 1072071097 1071841833 1071809381 1071710686 1071580105 1071482003 1071383725 1071154701 1070499431 1070335288 1070334157 1069943617 1069681476 1069584279 1069581771 1069322519 1069189353 1069125955 1068832186 1068797487 1068662939 1068565681 1...

output:

12623259

result: