QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#639649 | #9220. Bus Analysis | Loging | WA | 2ms | 4928kb | C++14 | 1.2kb | 2024-10-13 21:06:30 | 2024-10-13 21:06:30 |
Judging History
answer
#include<cstdio>
#include<algorithm>
#include<cstring>
#define P 1000000007
#define M 75
using namespace std;
int dp[2][M][M][M];
int F[7];
int Pw[M];
void Add(int &x,int y){
x=(x+y)%P;
}
int A[1005];
int main(){
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&A[i]);
Pw[0]=1;
for(int i=1;i<M;i++)Pw[i]=Pw[i-1]*2ll%P;
int cur=1;
dp[1][0][0][0]=1;
int ans=0;
for(int i=1;i<=n;i++){
memset(dp[!cur],0,sizeof(dp[!cur]));
int cost=A[i]-A[i-1];
for(int a=0;a<=70;a++){
for(int b=a;b<=70;b++){
for(int c=b;c<=70;c++){
if(dp[cur][a][b][c]==0)continue;
int na=max(0,a-cost);
int nb=max(0,b-cost);
int nc=max(0,c-cost);
for(int j=0;j<=6;j++)F[j]=0;
F[0]=na;F[1]=nb;F[2]=nc;
for(int j=0;j<=6;j++){
if(j+1<=6)F[j+1]=max(F[j+1],F[j]+20);
if(j+3<=6)F[j+3]=max(F[j+3],F[j]+75);
if(j)F[j]=max(F[j],F[j-1]);
}
Add(dp[!cur][na][nb][nc],dp[cur][a][b][c]);
int j=0;
while(F[j]==0)j++;
Add(ans,1ll*dp[cur][a][b][c]*Pw[n-i]%P*j%P);
Add(dp[!cur][F[j]][F[j+1]][F[j+2]],dp[cur][a][b][c]);
}
}
}
cur=!cur;
}
ans=ans*2ll%P;
printf("%d\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4928kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 4828kb
input:
5 25 45 65 85 1000000000
output:
62
result:
wrong answer 1st numbers differ - expected: '156', found: '62'