fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. map<pair<int,int>,int>mp;
  7. int n;
  8. cin>>n;
  9. int a[n],y=0;
  10. for(int i=0;i<n;++i)cin>>a[i];
  11. for(int i=0;i<n;++i)
  12. {
  13. mp[make_pair(y+1,y+a[i])]=i+1;
  14. y=a[i];
  15. }
  16. int m;
  17. cin>>m;
  18. int q[m];
  19. for(int i=0;i<m;++i)cin>>q[i];
  20. for(int i=0;i<m;++i)
  21. {
  22. int temp=q[i];
  23. for(map<pair<int,int>,int>::iterator it=mp.begin();it!=mp.end();++it)
  24. {
  25. if(((it->first.first)<=temp)&&((it->first.second)>=temp))
  26. {
  27. cout<<it->second<<endl;
  28. }
  29. }
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0s 3280KB
stdin
5
2 7 3 4 9
2
1 25 
stdout
1