Codeforces 474B. Worms solution
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,m,i,l,v;
- cin>>n;
- int a[n+9];
- cin>>a[0];
- for(i=1; i<n; i++)
- {
- cin>>a[i];
- a[i]+=a[i-1];
- }
- cin>>m;
- for(i=0; i<m; i++)
- {
- cin>>v;
- l=lower_bound(a,a+n,v)-a;
- cout<<l+1<<endl;
- }
- }
No comments