66372023-12-14 08:33:47Huni136Zenehallgatáscpp17Wrong answer 0/50263ms5308 KiB
#include <iostream>
#include <vector>
using namespace std;

vector<int> a(100002);
int binkeres(int x, int kezd, int veg)
{
     int kozep;
    while(kezd<=veg)
    {
       kozep=(kezd+veg)/2;
       if(a[kozep]>=x && a[kozep-1]<x)
       {
            return kozep;
       }
       else if(a[kozep]<x && a[kozep+1]>=x)
       {
            return kozep+1;
       }
       else if(x>a[kozep])
       {
            kezd=kozep+1;
       }
       else
       {
            veg=kozep-1;
       }
    }
}


int main()
{
    int n,x,kdb;
    cin>>n>>kdb;
    a[0]=0;
    cin>>a[1];
    for(int i=2;i<=n;i++)
    {
        cin>>x;
        a[i]=a[i-1]+x;
    }
    int k;
    int hossz=a[n];
    for(int i=1;i<=kdb;i++)
    {
        cin>>k;
        k=k%(hossz);
        if(k==0)
        {
            cout<<n<<" ";
            continue;
        }
        int bal=1, jobb=n;

        bool talalt=false;

        while (bal<=jobb && !talalt)
        {
            //cout<<"bal "<<bal<<" jobb "<<jobb<<" *** ";


            int kozepe=(bal+jobb)/2;
            if(bal+1==jobb)
              if(x<=a[bal])
              {
                 cout<<bal<<" ";
                 talalt=true;
              }
              else
              {
                 cout<<jobb<<" ";
                 talalt=true;
              }
            else if(x<a[kozepe])
                jobb=kozepe;
            else
                bal=kozepe;

        }
    }
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms2516 KiB
2Time limit exceeded0/0256ms2744 KiB
3Wrong answer0/24ms2960 KiB
4Wrong answer0/26ms3148 KiB
5Wrong answer0/24ms3496 KiB
6Wrong answer0/34ms3608 KiB
7Wrong answer0/36ms3824 KiB
8Wrong answer0/36ms4032 KiB
9Wrong answer0/2193ms4196 KiB
10Time limit exceeded0/2261ms3260 KiB
11Time limit exceeded0/2215ms4468 KiB
12Time limit exceeded0/2259ms4552 KiB
13Time limit exceeded0/2263ms3908 KiB
14Time limit exceeded0/2257ms3728 KiB
15Time limit exceeded0/2246ms3860 KiB
16Time limit exceeded0/2257ms4900 KiB
17Time limit exceeded0/2259ms4960 KiB
18Wrong answer0/2181ms5052 KiB
19Time limit exceeded0/2252ms4252 KiB
20Time limit exceeded0/2248ms5288 KiB
21Wrong answer0/2178ms5288 KiB
22Wrong answer0/3182ms5308 KiB
23Wrong answer0/3179ms5232 KiB
24Wrong answer0/3177ms5232 KiB