cf B Inna and Candy Boxes

时间:2022-03-17 22:16:23

题意:输入n,然后输入n个数ai,再输入n个数bi,如果在1-ai中能找到两个数x,y,x和y可以相等,如果x+y=bi,答案加上x*y,否则减去1,让结果尽可能大,输出结果。

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define maxn 100100
using namespace std; int n;
ll a[maxn],b[maxn]; int main()
{
while(scanf("%d",&n)!=EOF)
{
memset(a,,sizeof(a));
memset(b,,sizeof(b));
for(int i=; i<=n; i++)
{
scanf("%lld",&a[i]);
}
for(int i=; i<=n; i++)
{
scanf("%lld",&b[i]);
}
ll ans=;
for(int i=; i<=n; i++)
{
if(b[i]==)
{
ans--;
continue;
}
if(b[i]-a[i]>a[i])
{
ans--;
continue;
}
if(b[i]%==)
ans+=(ll)((ll)(b[i]/)*(ll)(b[i]/));
else
ans+=(ll)((ll)(b[i]/)*(ll)(b[i]/+));
}
printf("%lld\n",ans);
}
return ;
}