122352024-12-10 10:47:50szasztundeZenehallgatáscpp17Time limit exceeded 15/50257ms1392 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
base15/50
1Accepted0/01ms320 KiB
2Time limit exceeded0/0247ms1332 KiB
3Accepted2/23ms320 KiB
4Accepted2/23ms320 KiB
5Accepted2/23ms320 KiB
6Accepted3/33ms320 KiB
7Accepted3/33ms320 KiB
8Accepted3/33ms320 KiB
9Time limit exceeded0/2257ms1196 KiB
10Time limit exceeded0/2250ms1240 KiB
11Time limit exceeded0/2254ms1212 KiB
12Time limit exceeded0/2247ms1332 KiB
13Time limit exceeded0/2246ms1200 KiB
14Time limit exceeded0/2254ms1208 KiB
15Time limit exceeded0/2252ms1264 KiB
16Time limit exceeded0/2246ms1168 KiB
17Time limit exceeded0/2245ms1336 KiB
18Time limit exceeded0/2250ms1168 KiB
19Time limit exceeded0/2250ms1228 KiB
20Time limit exceeded0/2241ms1288 KiB
21Time limit exceeded0/2241ms1392 KiB
22Time limit exceeded0/3247ms1316 KiB
23Time limit exceeded0/3246ms1320 KiB
24Time limit exceeded0/3218ms1344 KiB