bzoj3412: [Usaco2009 Dec]Music Notes乐谱
来源:互联网 发布:空中铁匠 知乎 编辑:程序博客网 时间:2024/04/27 21:22
前缀和+二分。有很多做法
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int a[50005];int find(int x,int l,int r){ int mid=l+r>>1; if(l==r) { return r; } else if(a[mid]==x) return mid; if(a[mid]>x) return find(x,l,mid); else return find(x,mid+1,r);}int main(){ int n,x,q,t; cin>>n>>q; for(int i=1;i<=n;i++) { scanf("%d",&x); a[i]=a[i-1]+x; } for(int i=1;i<=q;i++) { scanf("%d",&t); printf("%d\n",find(t+1,1,n)); }}
阅读全文
0 0
- bzoj3412 [Usaco2009 Dec]Music Notes乐谱
- bzoj3412: [Usaco2009 Dec]Music Notes乐谱
- bzoj 3412: [Usaco2009 Dec]Music Notes乐谱
- bzoj 3412: [Usaco2009 Dec]Music Notes乐谱
- USACO 2009 Dec Silver 2.Music Notes
- bzoj1774【Usaco2009 Dec】Toll 过路费
- bzoj1774 [Usaco2009 Dec]Toll 过路费
- Flat - Music scores and guitar tabs editor(乐谱编辑器)
- 乐谱
- 乐谱
- 【BZOJ 1774】 [Usaco2009 Dec]Toll 过路费
- Bzoj1775 [Usaco2009 Dec]Vidgame 电视游戏问题
- Bzoj 1774 [Usaco2009 Dec]Toll 过路费
- BZOJ 1774 [Usaco2009 Dec] Toll 过路费
- (bzoj 1774 [Usaco2009 Dec]Toll 过路费)
- 1775: [Usaco2009 Dec]Vidgame 电视游戏问题
- bzoj3411 [Usaco2009 Dec]Bobsledding 高山滑雪
- NOJ 1616Music Notes 二分
- 计算机网络课程笔记(一)
- JSP中循环出半年的日历
- C++知识库
- 139. Word Break
- C# 文件操作笔记
- bzoj3412: [Usaco2009 Dec]Music Notes乐谱
- 【javaweb】-- Tomcat startup.bat 闪退,启动失败
- 28款GitHub最流行的开源机器学习项目
- 138. Copy List with Random Pointer
- 安装Windows10 和环境下的caffe(新版)
- android 用户授权
- APK的Dex文件结构和它的方法数统计分析
- bzoj2431: [HAOI2009]逆序对数列
- YUV fullrange