CF390B.Inna, Dima and Song

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 ii -th note at volume vv ( 1<=v<=ai1<=v<=a_{i} ; vv is an integer) both on the piano and the guitar. They should retain harmony, so the total volume with which the ii -th note was played on the guitar and the piano must equal bib_{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 ii -th note at volumes xix_{i} and yiy_{i} (xi+yi=bi)(x_{i}+y_{i}=b_{i}) correspondingly, Sereja's joy rises by xiyix_{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!

输入格式

The first line of the input contains integer nn (1<=n<=105)(1<=n<=10^{5}) — the number of notes in the song. The second line contains nn integers aia_{i} (1<=ai<=106)(1<=a_{i}<=10^{6}) . The third line contains nn integers bib_{i} (1<=bi<=106)(1<=b_{i}<=10^{6}) .

输出格式

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

输入输出样例

  • 输入#1

    3
    1 1 2
    2 2 3
    

    输出#1

    4
    
  • 输入#2

    1
    2
    5
    

    输出#2

    -1
    

说明/提示

In the first sample, Dima and Inna play the first two notes at volume 11 ( 1+1=21+1=2 , the condition holds), they should play the last note at volumes 11 and 22 . Sereja's total joy equals: 11+11+12=41·1+1·1+1·2=4 .

In the second sample, there is no such pair (x,y)(x,y) , that 1<=x,y<=21<=x,y<=2 , x+y=5x+y=5 , so Dima and Inna skip a note. Sereja's total joy equals -1.

首页