Inna, Dima and Song time limit per test 1 second memory limit per test megabytes input standard input output standard Output
Inna is a great piano player and Dima are a modest guitar player. Dima have recently written a song and they want to play it together. Of course, Sereja wants to listen to the song very much.
A song is a sequence of notes. Dima and Inna want to play each note at the same time. At this, they can play the i-th Note at volume V (1≤v≤ai; v is a integer) both on the piano and the guitar. They should retain harmony, so the all volume with which the i-th note is played on the guitar and the piano must equal Bi. If Dima and Inna cannot play a note by the described rules, they skip it and Sereja's joy drops by 1. But if Inna and Dima play the i-th note at Volumes Xi and Yi (xi + yi = bi) correspondingly, Sereja ' s joy rises Byxi Yi.
Sereja have just returned home from the university and his current joy is 0. Help Dima and Inna play the song so as to maximize Sereja's total joy after listening to the whole song! Input
The first line of the input contains an integer n (1≤n≤105)-the number of notes in the song. The second line contains n integers ai (1≤ai≤106). The third line contains n integers bi (1≤bi≤106). Output
In a single line print an integer-the maximum possible joy Sereja feels after he listens to a song. Sample Test (s) input
3
1 1 2
2 2 3
Output
4
Input
1
2
5
Output
-1
Note
In the first sample, Dima and Inna play the first of the Notes at Volume 1 (1 + 1 = 2, the condition holds), they should play The last note at Volumes 1 and 2. Sereja ' s total Joy equals:1 1 + 1 1 + 1・2 = 4.
In the second sample, there are no such pair (x, y), that 1≤x, y≤2, x + y = 5, so Dima and inna skip a note. Sereja ' s total Joy equals-1.
This code does not pass .....
#include <stdio.h>
int n,a[1000009],b[1000009];
int main ()
{
int i,j,k,bo;
__int64 Yu;
scanf ("%d", &n);
Yu = 0;
for (i = 0;i<n;i++)
{
scanf ("%lld", &a[i]);
}
for (i = 0;i<n;i++)
{
scanf ("%d", &b[i]);
}
for (i = 0;i<n;i++)
{
bo = 0;
for (j = 1;j<=a[i];j++)
{for
(k = 1;k <= a[i];k++)
{
if (j + k = = B[i])
{
bo = 1;
break;
}
}
if (bo = = 1) break
;
}
if (bo = = 1)
yu = Yu + (j * k);
else if (bo = = 0)
yu = yu-1;
}
printf ("%i64d\n", Yu);
return 0;
}