Codeforces Round #207 (Div. 2) A. Group of Students
#include <iostream>
#include <vector> using namespace std; int main(){
int m,sum = ;
cin >> m ;
vector<int> c(m+,);
for(int i = ; i <= m ; ++ i) {cin >> c[i];sum+=c[i];}
int x,y,firstPart = , secondPart = ,firstIndex = , secondIndex =;
cin >> x >> y;
for(firstIndex = ,secondIndex = m+;firstIndex < secondIndex;){
if (firstPart < x) firstPart+=c[++firstIndex];
if (secondPart < x) secondPart += c[--secondIndex];
if( firstPart >= x && secondPart >= x ) break;
}
if(firstPart > y || secondPart > y) cout<<<<endl;
else{
if(firstIndex >= secondIndex) cout<<<<endl;
else{
if(sum - firstPart - secondPart > *(y-x)) cout<<<<endl;
else{
while(secondPart + c[secondIndex-]<= y && (secondIndex-) > firstIndex){
secondIndex--;
secondPart+=c[secondIndex];
}
if (secondIndex- <= firstIndex) cout<<secondIndex<<endl;
else{
if(sum - secondPart > y) cout<<<<endl;
else cout<<secondIndex<<endl;
}
}
}
}
}
Codeforces Round #207 (Div. 2) A. Group of Students的更多相关文章
- Codeforces Round #207 (Div. 2)A B C E 水 思路 set 恶心分类
A. Group of Students time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #207 (Div. 1) A. Knight Tournament (线段树离线)
题目:http://codeforces.com/problemset/problem/356/A 题意:首先给你n,m,代表有n个人还有m次描述,下面m行,每行l,r,x,代表l到r这个区间都被x所 ...
- Codeforces Round #207 (Div. 1) A. Knight Tournament(STL)
脑子又卡了...来一发set的,STL真心不熟. #include <stdio.h> #include <string.h> #include <iostream> ...
- Codeforces Round #207 (Div. 1)B(数学)
数学so奇妙.. 这题肯定会有一个循环节 就是最小公倍数 对于公倍数内的相同的数的判断 就要借助最大公约数了 想想可以想明白 #include <iostream> #include< ...
- Codeforces Round #207 (Div. 2)C
读错题意了..线段树延迟标记 白刷这么多线段树 #include <iostream> #include<cstdio> #include<cstring> #in ...
- Codeforces Round #207 (Div. 2)
A:超级大水题: 代码: #include<cstdio> #define maxn 105 using namespace std; int n,a[maxn],x,y,ans; int ...
- Codeforces Round #207 (Div. 1) B. Xenia and Hamming(gcd的运用)
题目链接: B. Xenia and Hamming 题意: 要求找到复制后的两个字符串中不同样的字符 思路: 子问题: 在两串长度是最大公倍数的情况下, 求出一个串在还有一个串中反复字符的个数 CO ...
- Codeforces Round #207 (Div. 1) D - Bags and Coins 构造 + bitset优化dp + 分段查找优化空间
D - Bags and Coins 思路:我们可以这样构造,最大的那个肯定是作为以一个树根,所以我们只要找到一个序列a1 + a2 + a3 .... + ak 并且ak为 所有点中最大的那个,那么 ...
- Codeforces Round #207 (Div. 1) B (gcd的巧妙运用)
比赛的时候不知道怎么写... 太弱了. 看了别人的代码,觉得这个是个经典的知识点吧. gcd的巧妙运用 自己想的时候苦苦思考怎么用dp求解. 无奈字符串太长而想不出好的算法. 其实在把a和b字符串都分 ...
随机推荐
- javascript return false 详解
在大多数情况下,为事件处理函数返回false,可以防止默认的事件行为.例如,默认情况下点击一个<a>元素,页面会跳转到该元素href属性指定的页. Return False 就相当于终止符 ...
- HDOJ 1690
Bus System Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- jquery check box
if ($("#eulaLine").is(':checked')) { var mobile = $("#mobile").val(); if (mobile ...
- Python之property装饰器
参考: http://www.cnblogs.com/lovemo1314/archive/2011/05/03/2035600.html http://joy2everyone.iteye.com/ ...
- eclipse debug source not fount
1.选择Edit Source Lookup Path 2.选择Add 3.选择Java Project 4.选择相应的Project 进行OK确定即可 注意:做完以上的操作,要清除一下原来的断点,然 ...
- CI框架初探
2014年7月3日 17:39:35 简易版: index.php->codeIgniter.php->找到控制器类文件并include->创建实例->执行成员函数 详细版本: ...
- Linux下配置JDK
下面以CentOS为例,详细说一下Linux下配置JDK的过程 首先按照约定俗成的习惯,将jdk放在/usr/local/java下,首先进入/usr/local然后新建一个目录java 然后我们需要 ...
- codeforces 374A Inna and Pink Pony 解题报告
题目链接:http://codeforces.com/problemset/problem/374/A 题目意思:给出一个 n 行 m 列 的棋盘,要将放置在坐标点为(i, j)的 candy 移动 ...
- Java内存分配和内存管理
首先是概念层面的几个问题: Java中运行时内存结构有哪几种? Java中为什么要设计堆栈分离? Java多线程中是如何实现数据共享的? Java反射的基础是什么? 然后是运用层面: 引用类型变量和对 ...
- php的socket通信(二)
案例一:代码详解 // 设置一些基本的变量$host = "192.168.1.99";$port = 1234;// 设置超时时间set_time_limit(0);// 创建一 ...