302052: CF390B. Inna, Dima and Song
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Inna, Dima and Song
题意翻译
伊娜是一个非常棒的钢琴家,而蒂玛是一个谦逊的吉他手。蒂玛最近写了一首歌,并且两人想要一起弹奏它。当然,塞蕾嘉非常想听这首歌。 这首歌由一系列的音符组成。蒂玛和伊娜想同时弹奏每一个音符。这样他们就可以在两种乐器上都以 v 音量弹奏第 i 个音符了,但是 v 是正整数,且要小于等于 $a_i$。她们两个的弹奏应该保持和谐,所以总音量必须为 $b_i$。如果两人能这样谈,塞蕾嘉的心情就会上升两种乐器音量之积;不然,她的心情就要下降 1。塞蕾嘉刚从大学回来,心情为 0。 你的任务是帮助伊娜和蒂玛找到能使塞蕾嘉心情最好的弹奏方法。 ### 输入格式 第一行一个数,n,表示总音符数。 第二行 n 个数,即 $a_i$。 第三行 n 个数,即 $b_i$。 ### 输出格式 一个数,表示塞蕾嘉的最好心情。题目描述
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!输入输出格式
输入格式
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}) $ .
输出格式
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