QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#866756 | #8811. Heat Stroke | lgvc# | 7 | 29ms | 264716kb | C++23 | 1.6kb | 2025-01-22 18:18:50 | 2025-01-22 18:18:52 |
Judging History
answer
#include <bits/stdc++.h>
//0 qian j ge
//1 hou j ge
#define INF 0x3f3f3f3f
int N,L,va[8009],c[8009],la[8009][8009],vc[109][109][109][2];
std::vector<int> t[8009];
int sv(int n,int x,int y,int op) {
if(vc[n][x][y][op]!=-1) {
return vc[n][x][y][op];
}
if(n==N-1) {
if(x<c[n]&&(x-y)<va[n+1]) return INF;
return x;
}
int ans=INF;
for(int xx=0;xx<=c[n+1];xx++) {
int l1=0,l2=0;
if(xx<c[n+1]) l2=t[n+1][xx+1]-1;else l2=L;
if(x<c[n]) l1=t[n][x+1]-1;else l1=L;
int lim=std::min(l1,l2);
int tp1=la[lim][n],tp2=la[lim][n+1];
for(int yy=0;yy<=xx;yy++) {
int vv=va[n+1];
if(op==1) vv-=std::min(x-y,tp1);
else vv-=(std::max(std::min(x,tp1),y)-y);
int vt=vv-std::min(yy,tp2);
if((vt>=0)&&((xx==c[n+1]&&x==c[n])||(vt==0))) {
ans=std::min(ans,sv(n+1,xx,yy,0)+x);
}
vt=vv;
vt-=std::max(std::min(xx,tp2),xx-yy)-(xx-yy);
if((vt>=0)&&((xx==c[n+1]&x==c[n])||(vt==0))) {
ans=std::min(ans,sv(n+1,xx,yy,1)+x);
}
}
}
return vc[n][x][y][op]=ans;
}
signed main(void) {
memset(vc,-1,sizeof(vc));
scanf("%d",&N);
for(int i=1;i<=N;i++) {
scanf("%d",&va[i]);
t[i].push_back(0);
}
scanf("%d",&L);
for(int i=1;i<=L;i++) {
int x;
scanf("%d",&x);
t[x].push_back(i);
c[x]++;
for(int j=1;j<=N;j++) {
la[i][j]=la[i-1][j];
}
la[i][x]=t[x].size()-1;
}
int ans=0x3f3f3f3f;
for(int i=0;i<=c[1];i++) {
for(int j=0;j<=c[1]&&j<=va[1];j++) {
if((i==c[1])||(j==va[1])) ans=std::min(ans,sv(1,i,j,0));
if((i==c[1])||(j==va[1])) ans=std::min(ans,sv(1,i,j,1));
}
}
// printf("%d\n",sv(4,0,0,0));
printf("%d",L-ans);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 6
Accepted
time: 0ms
memory: 15064kb
input:
2 0 0 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 6
Accepted
time: 1ms
memory: 14976kb
input:
2 0 1 1 1
output:
0
result:
ok single line: '0'
Test #3:
score: 6
Accepted
time: 0ms
memory: 14684kb
input:
2 1 0 1 1
output:
0
result:
ok single line: '0'
Test #4:
score: 6
Accepted
time: 1ms
memory: 15640kb
input:
2 1 1 1 1
output:
0
result:
ok single line: '0'
Test #5:
score: 6
Accepted
time: 0ms
memory: 13952kb
input:
2 2 2 1 1
output:
0
result:
ok single line: '0'
Test #6:
score: 6
Accepted
time: 1ms
memory: 14664kb
input:
2 1 1 2 1 1
output:
0
result:
ok single line: '0'
Test #7:
score: 6
Accepted
time: 1ms
memory: 14492kb
input:
2 2 2 2 1 1
output:
0
result:
ok single line: '0'
Test #8:
score: 6
Accepted
time: 0ms
memory: 14288kb
input:
2 3 3 2 1 1
output:
0
result:
ok single line: '0'
Test #9:
score: 6
Accepted
time: 0ms
memory: 34232kb
input:
2 298 299 600 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
3
result:
ok single line: '3'
Test #10:
score: 6
Accepted
time: 5ms
memory: 124244kb
input:
2 1749 1749 3500 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
2
result:
ok single line: '2'
Test #11:
score: 6
Accepted
time: 29ms
memory: 264136kb
input:
2 3999 3999 8000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
2
result:
ok single line: '2'
Test #12:
score: 6
Accepted
time: 2ms
memory: 264716kb
input:
2 1 1 8000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
7998
result:
ok single line: '7998'
Test #13:
score: 6
Accepted
time: 1ms
memory: 229708kb
input:
2 0 0 8000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
8000
result:
ok single line: '8000'
Test #14:
score: 6
Accepted
time: 1ms
memory: 16844kb
input:
3 0 1 1 2 1 2
output:
0
result:
ok single line: '0'
Test #15:
score: 6
Accepted
time: 2ms
memory: 14312kb
input:
3 1 1 1 3 1 2 2
output:
1
result:
ok single line: '1'
Test #16:
score: 6
Accepted
time: 0ms
memory: 15000kb
input:
3 1 2 0 3 1 1 2
output:
1
result:
ok single line: '1'
Test #17:
score: 6
Accepted
time: 0ms
memory: 15416kb
input:
3 1 2 0 3 1 2 2
output:
1
result:
ok single line: '1'
Test #18:
score: 6
Accepted
time: 0ms
memory: 14832kb
input:
3 1 3 0 4 1 1 1 2
output:
1
result:
ok single line: '1'
Test #19:
score: 6
Accepted
time: 0ms
memory: 15700kb
input:
4 0 2 1 1 4 1 1 2 3
output:
0
result:
ok single line: '0'
Test #20:
score: 6
Accepted
time: 0ms
memory: 15832kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 33 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17
output:
15
result:
ok single line: '15'
Test #21:
score: 0
Wrong Answer
time: 15ms
memory: 123276kb
input:
8000 0 2 0 0 0 0 0 0 1 0 0 2 1 1 0 1 1 0 2 2 0 0 0 1 1 0 0 0 0 1 1 1 2 3 0 2 2 0 0 1 0 1 2 1 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 2 0 0 0 0 0 1 0 1 1 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 2 2 0 3 2 0 0 0 0 0 1 1 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 1 3 0...
output:
3408
result:
wrong answer 1st lines differ - expected: '843', found: '3408'
Subtask #2:
score: 7
Accepted
Test #33:
score: 7
Accepted
time: 0ms
memory: 14996kb
input:
3 1 1 1 3 1 2 1
output:
1
result:
ok single line: '1'
Test #34:
score: 7
Accepted
time: 1ms
memory: 15572kb
input:
3 1 1 1 3 2 1 2
output:
1
result:
ok single line: '1'
Test #35:
score: 7
Accepted
time: 1ms
memory: 15412kb
input:
7 1 1 1 1 1 1 1 8 2 1 6 5 4 3 2 6
output:
3
result:
ok single line: '3'
Test #36:
score: 7
Accepted
time: 0ms
memory: 15408kb
input:
8 1 1 1 1 1 1 1 1 10 6 7 4 1 2 3 4 5 6 1
output:
4
result:
ok single line: '4'
Test #37:
score: 7
Accepted
time: 0ms
memory: 15688kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 13 13 17 13 9 15 4 12 11 12 7 5 15 1
output:
1
result:
ok single line: '1'
Test #38:
score: 7
Accepted
time: 0ms
memory: 14656kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 17 12 6 3 15 17 3 10 6 12 15 17 11 12 14
output:
3
result:
ok single line: '3'
Test #39:
score: 7
Accepted
time: 1ms
memory: 15632kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 16 16 11 13 10 5 3 10 6 13 16 16 2 14 9 9 3
output:
4
result:
ok single line: '4'
Test #40:
score: 7
Accepted
time: 0ms
memory: 15392kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 17 12 5 4 1 10 6 8 8 16 6 12 14 7 14 17 12 9
output:
4
result:
ok single line: '4'
Test #41:
score: 7
Accepted
time: 1ms
memory: 15976kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 14 9 3 16 9 2 2 9 4 10 12 17 13 10 10 10 3 11
output:
7
result:
ok single line: '7'
Test #42:
score: 7
Accepted
time: 1ms
memory: 16316kb
input:
17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 15 9 6 3 13 9 13 16 7 5 8 1 1 9 9 15 16 1
output:
5
result:
ok single line: '5'
Test #43:
score: 7
Accepted
time: 0ms
memory: 16624kb
input:
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 13 4 8 8 13 8 1 15 3 6 4 8 6 4 12 9 15 14
output:
5
result:
ok single line: '5'
Test #44:
score: 7
Accepted
time: 0ms
memory: 16356kb
input:
15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 1 10 3 3 9 6 4 8 3 12 12 11 7 14 6 5 3 3
output:
6
result:
ok single line: '6'
Test #45:
score: 7
Accepted
time: 0ms
memory: 15512kb
input:
13 1 1 1 1 1 1 1 1 1 1 1 1 1 18 11 5 4 8 12 2 1 3 8 8 9 4 12 7 12 3 6 6
output:
7
result:
ok single line: '7'
Test #46:
score: 7
Accepted
time: 0ms
memory: 16560kb
input:
13 1 1 1 1 1 1 1 1 1 1 1 1 1 18 1 2 1 3 4 3 5 6 5 7 8 7 9 10 9 11 12 11
output:
6
result:
ok single line: '6'
Test #47:
score: 7
Accepted
time: 0ms
memory: 15356kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 1 5 7 11 13 17 2 4 8 10 14 16 1 5 7 11 13 17
output:
6
result:
ok single line: '6'
Test #48:
score: 7
Accepted
time: 0ms
memory: 16216kb
input:
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 15 1 3 2 4 6 5 7 9 8 10 12 11 13 15 14
output:
5
result:
ok single line: '5'
Test #49:
score: 7
Accepted
time: 0ms
memory: 16420kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 1 1 2 4 5 4 7 8 8 11 10 10 14 13 14 17 17 16
output:
4
result:
ok single line: '4'
Test #50:
score: 7
Accepted
time: 2ms
memory: 15100kb
input:
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 1 2 3 5 7 6 10 9 11 15 14 13
output:
1
result:
ok single line: '1'
Subtask #3:
score: 0
Wrong Answer
Dependency #2:
100%
Accepted
Test #51:
score: 0
Wrong Answer
time: 0ms
memory: 16380kb
input:
18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 33 17 17 16 16 15 15 14 14 13 13 12 12 11 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1
output:
16
result:
wrong answer 1st lines differ - expected: '15', found: '16'
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #6:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%