123972024-12-16 14:57:43szabelrZenehallgatáscpp17Accepted 50/5052ms1380 KiB
#include <iostream>
#include <vector>

using namespace std;
int a[100001]{0};
int keres(int y, int n)
{
    if(y<=a[1])
        return 1;
    int jo=0,kk,e=1,u=n;
    while(e<=u && !jo)
            {
                kk=(e+u)/2;
                if(a[kk]>=y && a[kk-1]<y) jo=kk;
                else if(a[kk+1]>=y && a[kk]<y) jo=kk+1;
                else if(y>a[kk]) e=kk+1;
                else u=kk-1;
            }
    return jo;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k,x,y,h;
    cin>>n>>k;
    for(int i=1; i<=n; i++){
        cin>>x;
        a[i]=a[i-1]+x;
    }
    for(int i=1; i<=k; i++){
        cin>>y;
        if(y>a[n])
            y=y%a[n];
        int mo=keres(y,n);
        cout<<mo<<" ";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms508 KiB
2Accepted0/052ms1328 KiB
3Accepted2/21ms320 KiB
4Accepted2/21ms500 KiB
5Accepted2/21ms320 KiB
6Accepted3/31ms320 KiB
7Accepted3/31ms320 KiB
8Accepted3/31ms320 KiB
9Accepted2/252ms1248 KiB
10Accepted2/252ms1204 KiB
11Accepted2/252ms1372 KiB
12Accepted2/252ms1332 KiB
13Accepted2/252ms1336 KiB
14Accepted2/250ms1328 KiB
15Accepted2/252ms1216 KiB
16Accepted2/252ms1288 KiB
17Accepted2/252ms1348 KiB
18Accepted2/250ms1340 KiB
19Accepted2/250ms1380 KiB
20Accepted2/250ms1328 KiB
21Accepted2/250ms1172 KiB
22Accepted3/350ms1312 KiB
23Accepted3/350ms1336 KiB
24Accepted3/348ms1348 KiB