QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#866783#8811. Heat Strokelgvc#0 38ms1034416kbC++231.7kb2025-01-22 18:38:002025-01-22 18:38:01

Judging History

你现在查看的是最新测评结果

  • [2025-01-22 18:38:01]
  • 评测
  • 测评结果:0
  • 用时:38ms
  • 内存:1034416kb
  • [2025-01-22 18:38:00]
  • 提交

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[100000009][2],su[8009];
std::vector<int> t[8009];
int sv(int n,int x,int y,int op) {
	int id=x*(c[n]+1)+y+su[n-1];
	if(n==N-1) {
		if(x<c[n]&&(x-y)<va[n+1]) return INF;
		return x;
	}
	if(vc[id][op]!=-1) {
		return vc[id][op];
	}
	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];
		int vv=va[n+1];
		if(op==1) vv-=std::min(x-y,tp1);
		else vv-=(std::max(std::min(x,tp1),y)-y);			
		for(int yy=0;yy<=xx;yy++) {
			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);				
				break;
			}
		}
		for(int yy=0;yy<=xx;yy++) {		
			int vt=vv-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);
				break;
			}
		}
	}
	return vc[id][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;
	}
	for(int i=1;i<=N;i++) {
		su[i]=su[i-1]+(c[i]+1)*(c[i]+1)+1;
	}
	int ans=0x3f3f3f3f;
	for(int i=0;i<=c[1];i++) {
		for(int j=0;j<=i&&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: 31ms
memory: 785624kb

input:

2
0 0
1
1

output:

1

result:

ok single line: '1'

Test #2:

score: 6
Accepted
time: 26ms
memory: 786248kb

input:

2
0 1
1
1

output:

0

result:

ok single line: '0'

Test #3:

score: 6
Accepted
time: 28ms
memory: 785140kb

input:

2
1 0
1
1

output:

0

result:

ok single line: '0'

Test #4:

score: 6
Accepted
time: 26ms
memory: 786576kb

input:

2
1 1
1
1

output:

0

result:

ok single line: '0'

Test #5:

score: 6
Accepted
time: 28ms
memory: 785668kb

input:

2
2 2
1
1

output:

0

result:

ok single line: '0'

Test #6:

score: 6
Accepted
time: 29ms
memory: 786528kb

input:

2
1 1
2
1 1

output:

0

result:

ok single line: '0'

Test #7:

score: 6
Accepted
time: 31ms
memory: 786248kb

input:

2
2 2
2
1 1

output:

0

result:

ok single line: '0'

Test #8:

score: 6
Accepted
time: 28ms
memory: 785544kb

input:

2
3 3
2
1 1

output:

0

result:

ok single line: '0'

Test #9:

score: 6
Accepted
time: 28ms
memory: 804816kb

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: 27ms
memory: 894804kb

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: 38ms
memory: 1034196kb

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: 29ms
memory: 1034416kb

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: 28ms
memory: 1034360kb

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: 19ms
memory: 786024kb

input:

3
0 1 1
2
1 2

output:

0

result:

ok single line: '0'

Test #15:

score: 6
Accepted
time: 23ms
memory: 787144kb

input:

3
1 1 1
3
1 2 2

output:

1

result:

ok single line: '1'

Test #16:

score: 6
Accepted
time: 24ms
memory: 786368kb

input:

3
1 2 0
3
1 1 2

output:

1

result:

ok single line: '1'

Test #17:

score: 6
Accepted
time: 27ms
memory: 786716kb

input:

3
1 2 0
3
1 2 2

output:

1

result:

ok single line: '1'

Test #18:

score: 6
Accepted
time: 24ms
memory: 786812kb

input:

3
1 3 0
4
1 1 1 2

output:

1

result:

ok single line: '1'

Test #19:

score: 0
Wrong Answer
time: 29ms
memory: 786676kb

input:

4
0 2 1 1
4
1 1 2 3

output:

2

result:

wrong answer 1st lines differ - expected: '0', found: '2'

Subtask #2:

score: 0
Wrong Answer

Test #33:

score: 7
Accepted
time: 22ms
memory: 785132kb

input:

3
1 1 1
3
1 2 1

output:

1

result:

ok single line: '1'

Test #34:

score: 7
Accepted
time: 22ms
memory: 786316kb

input:

3
1 1 1
3
2 1 2

output:

1

result:

ok single line: '1'

Test #35:

score: 7
Accepted
time: 34ms
memory: 786248kb

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: 33ms
memory: 786900kb

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: 0
Wrong Answer
time: 29ms
memory: 787504kb

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:

-1061109554

result:

wrong answer 1st lines differ - expected: '1', found: '-1061109554'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

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%