1862021-02-04 00:05:48ncsZenehallgatáscpp14Accepted 50/5087ms4708 KiB
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){

  int n,k; 
  scanf("%d%d",&n,&k);
  vector<int> T(n);
  vector<int> P(k);
  for(int i=0;i<n;i++){
    scanf("%d",&T[i]);
  }
  for(int i=0;i<k;i++){
    scanf("%d",&P[i]);
  }



  int s=0;
  for(int i=0;i<n;i++){
    s += T[i];
    T[i] = s;
  }
  for(int i=0;i<k;i++){
    int p = P[i];
    if(0 == p){
      P[i]=1;
      continue;
    }
    int r = p % s;
    if(0 == r){
      P[i]=n;
      continue;
    }
    P[i]=int(lower_bound(T.begin(),T.end(),r)-T.begin())+1; 
  }
  for(int i=0;i<k;i++){
    printf("%d ",P[i]);
  }
  printf("\n");

  return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms1060 KiB
2Accepted0/052ms3088 KiB
3Accepted2/21ms1780 KiB
4Accepted2/21ms1748 KiB
5Accepted2/21ms1708 KiB
6Accepted3/31ms1808 KiB
7Accepted3/31ms1656 KiB
8Accepted3/31ms1708 KiB
9Accepted2/248ms3420 KiB
10Accepted2/250ms3588 KiB
11Accepted2/246ms3676 KiB
12Accepted2/248ms3672 KiB
13Accepted2/250ms4204 KiB
14Accepted2/252ms4216 KiB
15Accepted2/248ms4184 KiB
16Accepted2/248ms4184 KiB
17Accepted2/287ms4184 KiB
18Accepted2/248ms4184 KiB
19Accepted2/252ms4184 KiB
20Accepted2/252ms4184 KiB
21Accepted2/250ms4192 KiB
22Accepted3/350ms4572 KiB
23Accepted3/352ms4708 KiB
24Accepted3/346ms4696 KiB