QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#116897 | #149. Peru | youngsystem# | 0 | 51ms | 51056kb | C++20 | 1.8kb | 2023-06-30 10:09:19 | 2024-09-10 16:35:48 |
Judging History
你现在查看的是最新测评结果
- [2024-05-31 18:34:03]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-06-30 10:09:19]
- 提交
answer
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int a[2500005];
int que[2500005],ql,qr;
long long dp[2500005];
long long sta1[2500005];
int top1;
long long min1[2500005];
long long sta2[2500005];
int top2;
long long min2[2500005];
void popfirst()
{
if(top1>=1)top1--;
else
{
int mid=(top2+1)/2;
for(int i=mid;i>=1;i--)sta1[++top1]=sta2[i];
for(int i=mid+1;i<=top2;i++)sta2[i-mid]=sta2[i];
top2-=mid;
min1[1]=sta1[1];
for(int i=2;i<=top1;i++)min1[i]=min(min1[i-1],sta1[i]);
min2[1]=sta2[1];
for(int i=2;i<=top2;i++)min2[i]=min(min2[i-1],sta2[i]);
top1--;
}
}
void popback()
{
if(top2>=1)top2--;
else
{
int mid=(top1+1)/2;
for(int i=mid;i>=1;i--)sta2[++top2]=sta1[i];
for(int i=mid+1;i<=top1;i++)sta1[i-mid]=sta1[i];
top1-=mid;
min1[1]=sta1[1];
for(int i=2;i<=top1;i++)min1[i]=min(min1[i-1],sta1[i]);
min2[1]=sta2[1];
for(int i=2;i<=top2;i++)min2[i]=min(min2[i-1],sta2[i]);
top2--;
}
}
void pushback(long long x)
{
sta2[++top2]=x;
if(top2==1)min2[top2]=x;
else min2[top2]=min(x,min2[top2-1]);
}
long long findmin()
{
long long ans=1000000000000000000LL;
if(top1>=1)ans=min(ans,min1[top1]);
if(top2>=1)ans=min(ans,min2[top2]);
return ans;
}
int solve(int n,int k,int* S)
{
for(int i=1;i<=n;i++)a[i]=S[i-1];
ql=qr=1;
que[1]=0;
a[0]=2000000000;
for(int i=1;i<=n;i++)
{
while(qr>=ql&&que[ql]<i-k)
{
if(ql<qr)popfirst();
ql++;
}
while(qr>=ql&&a[que[qr]]<=a[i])
{
if(ql<qr)popfirst();
qr--;
}
dp[i]=1000000000000000000LL;
if(ql<=qr)pushback(dp[que[qr]]+a[i]);
que[++qr]=i;
dp[i]=findmin();
if(i>=k)dp[i]=min(dp[i],dp[i-k]+a[que[ql]]);
//printf("%d %d %d %lld\n",top1,top2,i,dp[i]);
}
int ans=0;
for(int i=1;i<=n;i++)ans=(23LL*ans+dp[i]%mod)%mod;
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 13984kb
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:
129352554
result:
wrong answer 1st lines differ - expected: '559335223', found: '129352554'
Subtask #2:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 9ms
memory: 21700kb
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:
947660259
result:
wrong answer 1st lines differ - expected: '677928817', found: '947660259'
Subtask #3:
score: 0
Wrong Answer
Test #34:
score: 0
Wrong Answer
time: 51ms
memory: 51056kb
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:
445813100
result:
wrong answer 1st lines differ - expected: '12623259', found: '445813100'