67552023-12-18 19:33:42szasztundeZenehallgatáscpp17Time limit exceeded 15/50300ms4336 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(!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/03ms1876 KiB
2Time limit exceeded0/0300ms1604 KiB
3Accepted2/26ms2304 KiB
4Accepted2/26ms2516 KiB
5Accepted2/26ms2724 KiB
6Accepted3/36ms2944 KiB
7Accepted3/36ms3156 KiB
8Accepted3/36ms3344 KiB
9Time limit exceeded0/2282ms3208 KiB
10Time limit exceeded0/2266ms3216 KiB
11Time limit exceeded0/2277ms3624 KiB
12Time limit exceeded0/2275ms3632 KiB
13Time limit exceeded0/2263ms3788 KiB
14Time limit exceeded0/2261ms3920 KiB
15Time limit exceeded0/2270ms4048 KiB
16Time limit exceeded0/2282ms4168 KiB
17Time limit exceeded0/2250ms4152 KiB
18Time limit exceeded0/2266ms4104 KiB
19Time limit exceeded0/2282ms4060 KiB
20Time limit exceeded0/2270ms4208 KiB
21Time limit exceeded0/2270ms4160 KiB
22Time limit exceeded0/3270ms4164 KiB
23Time limit exceeded0/3263ms4328 KiB
24Time limit exceeded0/3254ms4336 KiB