65802023-12-12 16:15:11Huni136Zenehallgatáscpp17Time limit exceeded 34/50293ms18600 KiB
#include <iostream>
#include <map>
#include <vector>
using namespace std;

map<int,int> vlmi;
vector<int> a(100002,1e9);

int binkeres(int x, int kezd, int veg)
{
    if(kezd<=veg)
    {
       int 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])
       {
            return binkeres(x,kozep+1,veg);
       }
       else
       {
            return binkeres(x,kezd,kozep-1);
       }
    }
}

int main()
{
    int n,x,kdb;
    cin>>n>>kdb;
    //vector<int> a(n+1);
    a[0]=0;
    cin>>a[1];
    for(int i=2;i<=n;i++)
    {
        cin>>x;
        a[i]=a[i-1]+x;
        //vlmi[prevveg]=i;
    }
    int k;
   // auto seg=vlmi.end();
    //prevveg++;
    int hossz=a[n];
    for(int i=1;i<=kdb;i++)
    {
        cin>>k;
        k=k%(hossz);
        if(k==0)
        {
            cout<<n<<" ";
            continue;
        }

        cout<<binkeres(k,0,n)<<" ";
        // //auto it=vlmi.begin();
        // while (it!=seg && it->first<k)
        // {
        //     it++;
        // }
        // //cout<<it->second<<" ";
    }
}
SubtaskSumTestVerdictTimeMemory
base34/50
1Accepted0/03ms2516 KiB
2Time limit exceeded0/0293ms3644 KiB
3Accepted2/24ms3896 KiB
4Accepted2/24ms3900 KiB
5Accepted2/24ms4116 KiB
6Accepted3/34ms4124 KiB
7Accepted3/34ms4352 KiB
8Accepted3/34ms4420 KiB
9Accepted2/2200ms5100 KiB
10Accepted2/2197ms6220 KiB
11Accepted2/2195ms6996 KiB
12Time limit exceeded0/2246ms7204 KiB
13Accepted2/2192ms9128 KiB
14Accepted2/2193ms9912 KiB
15Time limit exceeded0/2252ms10824 KiB
16Time limit exceeded0/2236ms11940 KiB
17Time limit exceeded0/2266ms11560 KiB
18Accepted2/2187ms13424 KiB
19Accepted2/2189ms14408 KiB
20Accepted2/2187ms15432 KiB
21Time limit exceeded0/2212ms16404 KiB
22Accepted3/3187ms17264 KiB
23Time limit exceeded0/3225ms16768 KiB
24Time limit exceeded0/3250ms18600 KiB