73462024-01-08 08:40:43szasztundeZenehallgatáscpp17Time limit exceeded 15/50300ms4308 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];
        if (x<a[1]) cout<<1<<" ";
        else if(x>a[n-1]) cout<<n<<" ";
        else{
            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/03ms1764 KiB
2Time limit exceeded0/0300ms1572 KiB
3Accepted2/26ms2200 KiB
4Accepted2/26ms2396 KiB
5Accepted2/26ms2604 KiB
6Accepted3/34ms2688 KiB
7Accepted3/36ms2688 KiB
8Accepted3/36ms2920 KiB
9Time limit exceeded0/2300ms2648 KiB
10Time limit exceeded0/2257ms2788 KiB
11Time limit exceeded0/2266ms2944 KiB
12Time limit exceeded0/2259ms3096 KiB
13Time limit exceeded0/2275ms3008 KiB
14Time limit exceeded0/2266ms3192 KiB
15Time limit exceeded0/2270ms3004 KiB
16Time limit exceeded0/2277ms3308 KiB
17Time limit exceeded0/2280ms3504 KiB
18Time limit exceeded0/2261ms3772 KiB
19Time limit exceeded0/2273ms3940 KiB
20Time limit exceeded0/2250ms3924 KiB
21Time limit exceeded0/2250ms4028 KiB
22Time limit exceeded0/3270ms4160 KiB
23Time limit exceeded0/3257ms4088 KiB
24Time limit exceeded0/3266ms4308 KiB