SHARE
TWEET

12

Najmul_Kabir Aug 26th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. using namespace std;
  5. int a[1000000];
  6.  
  7. int main()
  8. {
  9.     int n, m, k;
  10.     while(scanf("%d",&n)!=0)
  11.     {
  12.         a[0] = 0;
  13.         for(int i=1; i<=n; i++)
  14.         {
  15.             scanf("%d", &a[i]);
  16.             a[i] += a[i-1];
  17.         }
  18.         scanf("%d", &m);
  19.         for(int i=0; i<m; i++)
  20.         {
  21.             scanf("%d", &k);
  22.             printf("%d\n", lower_bound(a, a+n, k) - a);
  23.         }
  24.     }
  25.     return 0;
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top