67562023-12-18 19:36:11szasztundeZenehallgatáscpp17Time limit exceeded 15/50300ms3940 KiB
#include <iostream>

using namespace std;
int a[100001]={0};
int main()
{
    int n,k,x;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]=a[i-1]+a[i];
    }
    for(int i=1;i<=k;i++)
    {
        cin>>x;
        x=x%a[n];
        int e=1,u=n,jo=0;
        while(e<=u && !jo)
        {
            int kk=(e+u)/2;
            if(a[kk]>=x && a[kk-1]<x) jo=kk;
            else if(a[kk+1]>=x && a[kk]<x) jo=kk+1;
            else if(x>a[kk]) e++;
            else u--;
        }
        cout<<jo<<" ";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Accepted0/03ms1752 KiB
2Time limit exceeded0/0300ms1640 KiB
3Accepted2/26ms2152 KiB
4Accepted2/26ms2340 KiB
5Accepted2/26ms2560 KiB
6Accepted3/36ms2784 KiB
7Accepted3/36ms2896 KiB
8Accepted3/36ms3056 KiB
9Time limit exceeded0/2263ms2788 KiB
10Time limit exceeded0/2270ms2860 KiB
11Time limit exceeded0/2263ms3024 KiB
12Time limit exceeded0/2266ms3108 KiB
13Time limit exceeded0/2254ms3276 KiB
14Time limit exceeded0/2270ms3368 KiB
15Time limit exceeded0/2275ms3580 KiB
16Time limit exceeded0/2277ms3536 KiB
17Time limit exceeded0/2246ms3560 KiB
18Time limit exceeded0/2266ms3636 KiB
19Time limit exceeded0/2266ms3848 KiB
20Time limit exceeded0/2259ms3764 KiB
21Time limit exceeded0/2254ms3928 KiB
22Time limit exceeded0/3270ms3940 KiB
23Time limit exceeded0/3261ms3936 KiB
24Time limit exceeded0/3275ms3852 KiB