• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Codeforce Round #228 Div2 B

 

Sponsored by
In English По-русски
HaibaraAi | Logout
 
 
 
 
 
  • Home
  • Contests
  • Gym
  • Problemset
  • Groups
  • Rating
  • Help
  • Rockethon

 
 
Codeforces Round #229 (Div. 2)
Finished
Practice
Add to favourites
 
 
→ Practice
 
You are registered for practice. You can solve problems unofficially. Results can be found in the contest status and in the bottom of standings.
 
 
→ Submit?
 
Language:
Choose file:
Be careful: there is 50 points penalty for submission which fails the pretests or resubmission (except failure on the first test, denial of judgement or similar verdicts). "Passed pretests" submission verdict doesn't guarantee that the solution is absolutely correct and it will pass system tests.
 
 
→ Last submissions
 
SubmissionTimeVerdict
5965302 02/12/2014 07:09PM Accepted
5965291 02/12/2014 07:07PM Wrong answer on test 6
5965246 02/12/2014 07:01PM Wrong answer on test 4
 
 
→ Problem tags
 
 
 
 
 
implementation
 
 
 
 
math
No tag edit access
  •  
     
     
  • Problems
  • Submit
  • My submissions
  • Status
  • Hacks
  • Room
  • Standings
  • Custom test
B. Inna, Dima and Song
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ≤ ai; 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 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 by xi·yi.

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 ≤ 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 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.


Codeforces (c) Copyright 2010-2014 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time: 02/12/2014 07:11PM (p1).
 
 
 
 1 #pragma comment(linker,"/STACK:102400000,102400000")
 2 #include <cstdio>
 3 #include <vector>
 4 #include <cmath>
 5 #include <queue>
 6 #include <set>
 7 #include <cstring>
 8 #include <iostream>
 9 #include <algorithm>
10 using namespace std;
11 #define INF 0x7fffffff 
12 #define mod 1000000007
13 #define ll long long
14 #define maxn 1000005
15 #define pi acos(-1.0)
16 #define dis(a, b) sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y))
17 ll gcd(ll n, ll m){ return m ? gcd(m, n%m) : n; }
18 ll n, m, k, x, y;
19 struct node{int a, b;}p[maxn];
20 bool cmp(node a, node b){ return (a.a < b.a || a.a == b.a&&a.b < b.b); }
21 ll a[maxn], b[maxn], c[maxn];
22 int main(){
23     cin >> n;
24     for (int i = 0; i < n; i++)scanf("%I64d", &a[i]);
25     for (int i = 0; i < n; i++)scanf("%I64d", &b[i]);
26     for (int i = 0; i < n; i++){
27         if (b[i] == 1){ x--; continue; }
28         if (b[i] % 2 == 0 && a[i] >= b[i] / 2)x += b[i] * b[i] / 4;
29         if (b[i] % 2 == 0 && a[i] < b[i] / 2)x--;
30         if (b[i] % 2 == 1 && a[i] > b[i] / 2)x += b[i] / 2 * (b[i] / 2 + 1);
31         if (b[i] % 2 == 1 && a[i] <= b[i] / 2)x--;
32     }
33     cout << x << endl;
34     return 0;
35 }
View Code
posted @ 2014-02-12 23:12  HaibaraAi  阅读(81)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3