Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;typedef long double llf;typedef double fl;typedef string str;typedef pair<double, double> dd;
- typedef vector<int> vi;typedef vector<vector<int>> vvi;typedef vector<fl> vf;typedef vector<ll> vl;
- typedef vector<llf> vlf;typedef vector<char> vc;typedef vector<str> vs;typedef pair<int,int> ii;
- # define f(i,a,b,c) for(ll i=a;i<b;i+=c)
- # define fd(i,a,b,c) for(ll i=a;i>=b;i-=c)
- # define ctoi(a) (a-'0')
- # define pb push_back
- # define eb emplace_back
- # define be(x) x.begin(), x.end()
- # define rbe(x) x.rbegin(), x.rend()
- # define _(x) ios::sync_with_stdio(0);cin.tie(0);cout.precision(x);cout.setf(ios::fixed);
- const int MAX = 1e5;
- int n, m, au, q, ant=0, in, f, md, ns[MAX];
- int main(){
- cin>>n;
- f(i,0,n,1)cin>>au, ns[i] = ant+au, ant += au;
- cin>>m;
- f(i,0,m,1){
- cin>>q;
- in=0, f=n-1;
- while(in<f){
- md = in + (f-in)/2;
- if(q <= ns[md])f = md;
- else in = md + 1;
- }
- cout<<in+1<<'\n';
- }
- return 0;}
Add Comment
Please, Sign In to add comment