73612024-01-08 10:54:42szasztundeZenehallgatáscpp17Time limit exceeded 27/50266ms5008 KiB
#include <iostream>

using namespace std;
int a[100001]={0};
int main()
{
    int n,k,x,e,u,jo,kk;
    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{
            e=1; u=n; jo=0;
            while(e<=u && !jo)
            {
                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
base27/50
1Accepted0/03ms2156 KiB
2Time limit exceeded0/0252ms3048 KiB
3Accepted2/24ms2308 KiB
4Accepted2/24ms2500 KiB
5Accepted2/24ms2680 KiB
6Accepted3/34ms2852 KiB
7Accepted3/34ms2912 KiB
8Accepted3/34ms2912 KiB
9Time limit exceeded0/2222ms3680 KiB
10Accepted2/2199ms3808 KiB
11Time limit exceeded0/2221ms4300 KiB
12Time limit exceeded0/2261ms3144 KiB
13Accepted2/2194ms4324 KiB
14Time limit exceeded0/2261ms4364 KiB
15Time limit exceeded0/2229ms4260 KiB
16Time limit exceeded0/2234ms4264 KiB
17Accepted2/2194ms4264 KiB
18Accepted2/2190ms4496 KiB
19Accepted2/2192ms4616 KiB
20Accepted2/2190ms4688 KiB
21Time limit exceeded0/2245ms4812 KiB
22Time limit exceeded0/3259ms3756 KiB
23Time limit exceeded0/3254ms5008 KiB
24Time limit exceeded0/3266ms3768 KiB