Codeforces Round 229 (Div. 2)
B
Inna, Dima and Song
Codeforces
未评级
原题
← AC →
翻译中…

Inna is a great piano player and Dima is a modest guitar player. Dima has 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 that, they can play the $*i*$-th note at volume $*v*$ ($1 ≤ *v* ≤ *a*_{*i*}$; $*v*$ is an integer) both on the piano and the guitar. They should retain harmony, so the total volume with which the $*i*$-th note was played on the guitar and the piano must equal $*b*_{*i*}$. 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 $*x*_{*i*}$ and $*y*_{*i*}$ $(*x*_{*i*} + *y*_{*i*} = *b*_{*i*})$ correspondingly, Sereja's joy rises by $*x*_{*i*}·*y*_{*i*}$.

翻译中…

Sereja has 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 integer $*n*$ $(1 ≤ *n* ≤ 10^{5})$ — the number of notes in the song. The second line contains $*n*$ integers $*a*_{*i*}$ $(1 ≤ *a*_{*i*} ≤ 10^{6})$. The third line contains $*n*$ integers $*b*_{*i*}$ $(1 ≤ *b*_{*i*} ≤ 10^{6})$.

翻译中…

Output

翻译中…

In a single line print an integer — the maximum possible joy Sereja feels after he listens to a song.

翻译中…

Note

翻译中…

In the first sample, Dima and Inna play the first two 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 is 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.

翻译中…

样例

Input #1
3
1 1 2
2 2 3
Output #1
4
InputCopy OutputCopy
Input #2
1
2
5
Output #2
-1
InputCopy OutputCopy
题目信息
题号
390B
时间限制
1 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。