73482024-01-08 08:44:04szasztundeZenehallgatáscpp17Time limit exceeded 30/50270ms4904 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=kk+1;
                else u=kk-1;
            }
            cout<<jo<<" ";
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/50
1Accepted0/03ms1884 KiB
2Time limit exceeded0/0209ms3152 KiB
3Accepted2/24ms2616 KiB
4Accepted2/24ms2844 KiB
5Accepted2/24ms3004 KiB
6Accepted3/34ms3112 KiB
7Accepted3/34ms3128 KiB
8Accepted3/34ms3248 KiB
9Time limit exceeded0/2247ms2896 KiB
10Time limit exceeded0/2270ms3208 KiB
11Time limit exceeded0/2250ms3396 KiB
12Time limit exceeded0/2254ms4552 KiB
13Time limit exceeded0/2250ms3464 KiB
14Accepted2/2194ms4552 KiB
15Time limit exceeded0/2232ms4548 KiB
16Accepted2/2194ms4548 KiB
17Time limit exceeded0/2247ms4512 KiB
18Time limit exceeded0/2245ms4608 KiB
19Time limit exceeded0/2270ms3508 KiB
20Time limit exceeded0/2228ms4736 KiB
21Accepted2/2188ms4880 KiB
22Accepted3/3187ms4800 KiB
23Accepted3/3187ms4904 KiB
24Accepted3/3190ms4804 KiB