QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581272 | #9220. Bus Analysis | 2114992323 | WA | 5ms | 3692kb | C++14 | 1017b | 2024-09-22 11:24:09 | 2024-09-22 11:24:10 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int mod=1000000007;
int n,a[1010],b[1010],f[2][1010],cnt;
LL ans;
inline int read()
{
int x=0,w=0;char ch=getchar();
while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return w?-x:x;
}
int calc()
{
int temp=1e9;
memset(f,-0x3f,sizeof f);
cnt=b[0];b[0]=f[0][0]=0;
for(int i=1;i<=cnt;i++){
memset(f[i&1],-0x3f,sizeof f[i&1]);
for(int j=0;j<=i+3;j++)
if(f[(i-1)&1][j]>=0){
if(f[(i-1)&1][j]>=b[i]-b[i-1])
f[i&1][j]=max(f[i&1][j],f[(i-1)&1][j]-(b[i]-b[i-1]));
f[i&1][j+1]=max(f[i&1][j+1],19);
f[i&1][j+3]=max(f[i&1][j+3],74);
}
}
for(int i=0;i<=cnt;i++)
if(f[cnt&1][i]>=0)
temp=min(temp,i);
return temp;
}
int main()
{
n=read();
for(int i=1;i<=n;i++)
a[i]=read();
for(int i=0;i<(1<<n);i++){
b[0]=0;
for(int j=1;j<=n;j++)
if(i>>(j-1)&1)
b[++b[0]]=a[j];
(ans+=calc())%=mod;
}
cout<<ans*2%mod<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: -100
Wrong Answer
time: 5ms
memory: 3516kb
input:
1000 2 7 9 12 14 17 18 21 22 28 29 33 34 35 37 38 44 45 46 50 58 59 63 66 71 72 75 76 77 78 80 81 83 84 87 92 100 101 107 108 109 112 114 116 118 123 124 131 142 143 144 145 148 150 151 152 153 155 157 158 165 167 168 169 171 176 182 185 190 192 198 202 204 205 212 213 223 224 225 226 229 231 240 24...
output:
22576
result:
wrong answer 1st numbers differ - expected: '932594593', found: '22576'