124412024-12-17 22:07:49szasztundeZenehallgatáscpp17Time limit exceeded 15/50300ms804 KiB
#include <stdio.h>

using namespace std;
int a[100001]={0};
int main()
{
    int n,k,x;
    scanf("%d%d",&n,&k);//cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);//cin>>a[i];
        a[i]=a[i-1]+a[i];
    }
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&x);//cin>>x;
        x=x%a[n];
        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--;
        }
        printf("%d ",jo);//cout<<jo<<" ";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Accepted0/01ms320 KiB
2Time limit exceeded0/0280ms584 KiB
3Accepted2/23ms320 KiB
4Accepted2/23ms320 KiB
5Accepted2/22ms320 KiB
6Accepted3/32ms400 KiB
7Accepted3/32ms320 KiB
8Accepted3/32ms320 KiB
9Time limit exceeded0/2300ms776 KiB
10Time limit exceeded0/2300ms660 KiB
11Time limit exceeded0/2300ms724 KiB
12Time limit exceeded0/2280ms568 KiB
13Time limit exceeded0/2287ms688 KiB
14Time limit exceeded0/2287ms544 KiB
15Time limit exceeded0/2300ms780 KiB
16Time limit exceeded0/2286ms568 KiB
17Time limit exceeded0/2286ms568 KiB
18Time limit exceeded0/2286ms780 KiB
19Time limit exceeded0/2298ms572 KiB
20Time limit exceeded0/2287ms568 KiB
21Time limit exceeded0/2280ms568 KiB
22Time limit exceeded0/3280ms804 KiB
23Time limit exceeded0/3298ms780 KiB
24Time limit exceeded0/3284ms568 KiB