杭电acm3661题目意思,

2024-12-19 10:09:17
推荐回答(1个)
回答1:

#include
int main()
{
int n,t,a[1001],b[1001],c,i,j,tem;
while(scanf("%d%d",&n,&t)!=EOF)
{
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=1;i<=n;i++)
scanf("%d",&b[i]);
c=0;
for(i=0;i for(j=1;j<=n-i-1;j++)
{
if(a[j]>a[j+1])
{
tem=a[j];
a[j]=a[j+1];
a[j+1]=tem;
}
if(b[j]>b[j+1])
{
tem=b[j];
b[j]=b[j+1];
b[j+1]=tem;
}
}
for(i=1;i<=n;i++)
if(a[i]+b[n-i+1]>t)
c=c+a[i]+b[n-i+1]-t;
printf("%d\n",c);
}
return 0;
}