QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#122144 | #149. Peru | tuxiaoxiao | 0 | 41ms | 62468kb | C++14 | 1.2kb | 2023-07-09 15:57:45 | 2024-09-10 16:39:13 |
Judging History
answer
#include<bits/stdc++.h>
#include "peru.h"
#define f(i,x,y) for(int i=x;i<=y;i++)
#define df(i,x,y) for(int i=x;i>=y;i--)
#define ll long long
using namespace std;
const ll N=2.5e6+9,I=1e18,P=1e9+7;
ll n,a[N],x,k,y,z[N],zl,p[N],pl,f[N],fp[N],sz[N],sp[N],fl;
int as;
void rb(ll fg)
{
fl=0;
df(i,zl,1)fp[++fl]=z[i];
f(i,1,pl)fp[++fl]=p[i];
zl=(fl+fg)/2,pl=fl-zl;
df(i,pl,1)p[i]=fp[fl--];
z[1]=n+1;f(i,1,zl)z[i]=fp[fl--];
p[0]=z[1];
f(i,1,pl)sp[i]=min(f[p[i-1]]+a[p[i]],sp[i-1]);
f(i,2,zl)sz[i]=min(f[z[i]]+a[z[i-1]],sz[i-1]);
}
int solve(int N,int K,int *S)
{
n=N,k=K;
f(i,1,n)a[i]=S[i-1];
pl=zl=0;sz[0]=sz[1]=sp[0]=a[0]=f[n+1]=I;
as=0;
f(i,1,n)
{
if(pl+zl)
{
if(!zl||pl+zl==2)rb(2);
if(z[zl]+k<i)--zl;
}
while(pl+zl)
{
if(!pl)rb(0);
if(a[p[pl]]<=a[i])--pl;//cout<<p[pl],
else break;
}
// df(i,zl,1)cout<<z[i];f(i,1,pl)cout<<p[i];
p[++pl]=i;
if(pl+zl!=1)sp[pl]=min(f[p[pl-1]]+a[i],sp[pl-1]);else sp[pl]=I;
f[i]=min(sz[zl],sp[pl]);//cout<<pl;
if(zl)f[i]=min(f[max(i-k,0ll)]+a[z[zl]],f[i]);
else f[i]=min(f[max(i-k,0ll)]+a[p[1]],f[i]);
as=(as*23ll+f[i])%P;//cout<<f[i]<<' ';
}
return as;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 18
Accepted
time: 0ms
memory: 18144kb
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: 18292kb
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: 0
Wrong Answer
time: 3ms
memory: 18096kb
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:
304453151
result:
wrong answer 1st lines differ - expected: '722220390', found: '304453151'
Subtask #2:
score: 0
Wrong Answer
Test #15:
score: 31
Accepted
time: 7ms
memory: 25868kb
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: 0
Wrong Answer
time: 8ms
memory: 27892kb
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:
769651861
result:
wrong answer 1st lines differ - expected: '390755425', found: '769651861'
Subtask #3:
score: 0
Wrong Answer
Test #34:
score: 0
Wrong Answer
time: 41ms
memory: 62468kb
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:
825491843
result:
wrong answer 1st lines differ - expected: '12623259', found: '825491843'