QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#622230 | #5005. Geekflix | C1942huangjiaxu | WA | 0ms | 3980kb | C++14 | 1.2kb | 2024-10-08 20:24:14 | 2024-10-08 20:24:15 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3888kb
input:
3 10 10 10 10 5 3 1
output:
67
result:
ok single line: '67'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3952kb
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: 3980kb
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'