CF——#182div2B
来源:互联网 发布:淘宝怎么设置折扣价 编辑:程序博客网 时间:2024/04/30 03:53
B题地址:http://codeforces.com/contest/302/problem/B
注:好坑啊二分啊。
#include<iostream>
#include<cstring>#include<queue>#include<cstdio>#include<cmath>#include<algorithm>using namespace std;#define N 100005int a[N];int main(){ int n,m; int i,j,k; while(cin>>n>>m) { int st=0; int num1,num2; int mid; a[0]=0; for(i=1;i<=n;i++) { cin>>num1>>num2; a[i]=st+num1*num2; st=a[i]; } while(m--) { cin>>num1; int top=n; int bottom=0; int mid; while(bottom<=top) { mid=(top+bottom)/2; if(a[mid]<num1&&a[mid+1]>=num1) { cout<<mid+1<<endl; break; } if(a[mid]<num1) bottom=mid+1; else top=mid-1; } } }return 0;}
- CF——#182div2B
- CF——#150div2B
- 水题——codeforces#275div2B
- (贪心)Color the Fence - CF 202 Div2B
- 【CF】【318div2B】【暴力枚举】【度的应用】
- CF——#182div2C
- CF——Trace
- CF——Taxi
- CF—Hot Bath
- cf——#30A
- CF——#23C
- CF——Average Numbers
- cf——B. Garland
- CF——Next Round
- CF——Game Outcome
- CF —— IQ Test
- CF——Dishonest Sellers
- Codeforces R278 div2B 分类讨论
- “残缺”程序员的屌丝录(一)
- jQuery 04 事件和动画
- 第五章 运算符与表达式
- Linux下Ruby调用shell方法
- 黑马程序员-静态导入、可变参数、增强for、自动拆装箱
- CF——#182div2B
- jQuery 05 表单操作/表格操作
- Android之条码扫描二维码扫描
- 关于Android Repo
- jQuery 06 Ajax
- jQuery 07 编写插件
- [LIS]Longest Increasing Sequence:nlogn算法和两种普通DP的实现
- Ubuntu下编译android的linux内核
- &和&&的区别