cf B Inna and Candy Boxes
题意:输入n,然后输入n个数ai,再输入n个数bi,如果在1-ai中能找到两个数x,y,x和y可以相等,如果x+y=bi,答案加上x*y,否则减去1,让结果尽可能大,输出结果。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define maxn 100100
using namespace std; int n;
ll a[maxn],b[maxn]; int main()
{
while(scanf("%d",&n)!=EOF)
{
memset(a,,sizeof(a));
memset(b,,sizeof(b));
for(int i=; i<=n; i++)
{
scanf("%lld",&a[i]);
}
for(int i=; i<=n; i++)
{
scanf("%lld",&b[i]);
}
ll ans=;
for(int i=; i<=n; i++)
{
if(b[i]==)
{
ans--;
continue;
}
if(b[i]-a[i]>a[i])
{
ans--;
continue;
}
if(b[i]%==)
ans+=(ll)((ll)(b[i]/)*(ll)(b[i]/));
else
ans+=(ll)((ll)(b[i]/)*(ll)(b[i]/+));
}
printf("%lld\n",ans);
}
return ;
}
cf B Inna and Candy Boxes的更多相关文章
- cf C. Inna and Candy Boxes
题意:给你一个长度为n的只含有1和0的字符串,w个询问,每次询问输入l,r:在[l,r]中在l+k-1.l+2*k-1.......r的位置都必须为1,如果不为1的,变成1,记为一次操作,其它的地方的 ...
- Codeforces Round #229 (Div. 2) C. Inna and Candy Boxes 树状数组s
C. Inna and Candy Boxes Inna loves sweets very much. She has n closed present boxes lines up in a ...
- codeforces 390C Inna and Candy Boxes
这个题目看似不是很好下手,不过很容易发现每次询问的时候总是会问到第r个盒子是否有糖果: 这样的话就很好办事了: 维护两个数组: 一个sum数组:累加和: 一个in数组:如果i位是1的话,in[i]=i ...
- Brute Force - B. Candy Boxes ( Codeforces Round #278 (Div. 2)
B. Candy Boxes Problem's Link: http://codeforces.com/contest/488/problem/B Mean: T题目意思很简单,不解释. ana ...
- Codeforces 488B - Candy Boxes
B. Candy Boxes 题目链接:http://codeforces.com/problemset/problem/488/B time limit per test 1 second memo ...
- Codeforces Round #278 (Div. 2) B. Candy Boxes [brute force+constructive algorithms]
哎,最近弱爆了,,,不过这题还是不错滴~~ 要考虑完整各种情况 8795058 2014-11-22 06:52:58 njczy2010 B - Ca ...
- cf A. Inna and Pink Pony(思维题)
题目:http://codeforces.com/contest/374/problem/A 题意:求到达边界的最小步数.. 刚开始以为是 bfs,不过数据10^6太大了,肯定不是... 一个思维题, ...
- cf C. Inna and Dima
http://codeforces.com/contest/374/problem/C 记忆化搜索,题意:求按照要求可以记过名字多少次,如果次数为无穷大,输出Poor Inna!,如果不经过一次输出P ...
- cf B. Inna and Nine
http://codeforces.com/contest/374/problem/B #include <cstdio> #include <cstring> #includ ...
随机推荐
- [React] Linting React JSX with ESLint (in ES6)
ESLint is a JavaScript linter (static analysis tool) that offers full support for ES6, JSX, and othe ...
- [Flux] 3. Actions
Actions contain no functionality, but rather describe an event in our application. In this lesson we ...
- 理解 Linux 网络栈(1):Linux 网络协议栈简单总结 图
http://www.cnblogs.com/sammyliu/p/5225623.html
- 安全通信 QSslSocket
The QSslSocket class provides an SSL encrypted socket for both clients and servers. More... Header: ...
- JAAS authentication in Tomcat example--reference
In this tutorial you will learn how to configure JAAS authentication in Tomcat using the HTTP Basic ...
- CSS3渐变(Gradients)-线性渐变
CSS3渐变(Gradients)可以让你在两个或多个指定颜色之间显示平稳的过度,包括透明度. 以前,你必须使用图像来实现这些效果.但是,通过Css3渐变(Gradients),你可以减少下载的事件和 ...
- Android ListView 嵌套 ImageView,如何响应ImageView的点击和长按事件
http://www.tuicool.com/articles/EZv2Uv 1.先说下嵌套在ListView中的ImageView如何响应点击事件 方法:在imageView中设置onClick属性 ...
- android menu菜单自动生成
Android提供了一些简单的方法来为应用添加Menu菜单. 提供了三种类型应用菜单: 一.Options Menu:通过Menu按钮调用菜单 1.在/res/目录下新建menu文件夹,用于存储Men ...
- 【转】 IOS,objective_C中用@interface和 @property 方式声明变量的区别
原文: http://blog.csdn.net/ganlijianstyle/article/details/7924446 1.在 @interface :NSObject{} 的括号中,当然N ...
- UILabel的高度自适应
_content = [UILabel new]; _content.text = @"日落时分,沏上一杯山茶,听一曲意境空远的<禅>,心神随此天籁,沉溺于玄妙的幻境里.仿佛我就 ...