124022024-12-16 15:46:51KissCsongor777Zenehallgatáscpp17Time limit exceeded 15/50261ms1368 KiB
#include <iostream>

using namespace std;

int P[100001];

int main()
{
    int n,k,m,x,j,e,u,c,h,y;
    cin>>n>>k;
    for(int i=1; i<=n; i++){cin>>P[i];P[i]+=P[i-1];}
    for(int i=1; i<=k; i++)
        {
            cin>>x;
            x=x%P[n];
            if(x<=P[1])cout<<1<<" ";
            else if (P[n-1]<x) cout<<n<<" ";
            else{
            e=1; u=n;
            h=false;
            y=1;
            while(!h && e<=u)
            {
                c=(e+u)/2;
                if(P[c]>=x && P[c-1]<x){y=c;h=true;}
                else if (P[c+1]>=x && P[c]<x){y=c+1; h=true;}
                else if (x>P[c]) e=c+1;
                else u=c-1;
            }
            cout<<y<<" ";}

        }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Accepted0/01ms320 KiB
2Time limit exceeded0/0252ms1336 KiB
3Accepted2/23ms320 KiB
4Accepted2/23ms508 KiB
5Accepted2/23ms320 KiB
6Accepted3/33ms320 KiB
7Accepted3/33ms320 KiB
8Accepted3/33ms320 KiB
9Time limit exceeded0/2261ms1280 KiB
10Time limit exceeded0/2254ms1332 KiB
11Time limit exceeded0/2259ms1336 KiB
12Time limit exceeded0/2250ms1336 KiB
13Time limit exceeded0/2250ms1336 KiB
14Time limit exceeded0/2257ms1360 KiB
15Time limit exceeded0/2257ms1196 KiB
16Time limit exceeded0/2247ms1336 KiB
17Time limit exceeded0/2247ms1192 KiB
18Time limit exceeded0/2250ms1336 KiB
19Time limit exceeded0/2250ms1336 KiB
20Time limit exceeded0/2243ms1336 KiB
21Time limit exceeded0/2250ms1340 KiB
22Time limit exceeded0/3244ms1336 KiB
23Time limit exceeded0/3248ms1348 KiB
24Time limit exceeded0/3222ms1368 KiB