QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622225#5005. GeekflixC1942huangjiaxuWA 0ms4172kbC++141.2kb2024-10-08 20:22:002024-10-08 20:22:00

Judging History

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

  • [2024-10-08 20:22:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4172kb
  • [2024-10-08 20:22:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1005;
typedef vector<int> vi;
vi t[N],pr[N],su[N],s1[N],s2[N];
int n,m,a[N],b[N],ans;
vi operator +(vi a,vi b){
	vi c(a.size()+b.size());
	merge(a.begin(),a.end(),b.begin(),b.end(),c.begin(),greater<>());
	c.resize(m);
	return c;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)scanf("%d",&b[i]);
	for(int i=1;i<=n;++i){
		t[i].resize(m);
		for(int j=0;j<m;++j)t[i][j]=max(0,a[i]-j*b[i]);
	}
	for(int i=1;i<=n;++i)pr[i]=pr[i-1]+t[i];
	for(int i=n;i;--i)su[i]=su[i+1]+t[i];
	for(int i=1;i<=n;++i){
		s1[i].resize(m),s2[i].resize(m);
		for(int j=0;j<m;++j){
			s1[i][j]=pr[i][j],s2[i][j]=su[i][j];
			if(j)s1[i][j]+=s1[i][j-1],s2[i][j]+=s2[i][j-1];
		}
	}
	su[n+1].resize(m),s2[n+1].resize(m);
	for(int i=1,k1,k2;i<=n;++i){
		k1=m-1,k2=-1;
		for(int j=n+1;j>i;--j){
			int d=i-1+n+1-j+min(i-1,n+1-j);
			d=m-d;
			if(d<=0)break;
			while(k1+k2+2>d){
				if(k2==-1||pr[i][k1]<su[j][k2])--k1;
				else --k2;
			}
			while(~k1&&pr[i][k1]<su[j][k2+1])--k1,++k2;
			ans=max(ans,(~k1?s1[i][k1]:0)+(~k2?s2[j][k2]:0));
		}
	}
	printf("%d\n",ans);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3924kb

input:

3 10
10 10 10
5 3 1

output:

67

result:

ok single line: '67'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3916kb

input:

5 10
1 2 3 4 5
0 1 2 3 4

output:

16

result:

ok single line: '16'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 4172kb

input:

5 5
1 5000 1 1 5000
1 3000 1 1 3000

output:

14000

result:

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