73592024-01-08 10:48:55szasztundeZenehallgatáscpp17Wrong answer 0/50279ms5228 KiB
#include <iostream>
#include <vector>
using namespace std;
vector <int> a;
int main()
{
    int n,k,x;
    cin>>n>>k;
    cin>>x;
    a.push_back(x);
    for(int i=2;i<=n;i++)
    {
        cin>>x;
        x=x+a.back();
        a.push_back(x);
    }

    for(int i=1;i<=k;i++)
    {
        cin>>x;
        x=x%a[n-1];
        if (x<a[0]) cout<<1<<" ";
        else if(x>a[n-1]) cout<<n<<" ";
        else{
            int e=0,u=n-1,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=kk+1;
                else u=kk-1;
            }
            cout<<jo<<" ";
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms2024 KiB
2Time limit exceeded0/0226ms2040 KiB
3Wrong answer0/24ms2392 KiB
4Wrong answer0/24ms2624 KiB
5Wrong answer0/24ms2804 KiB
6Wrong answer0/34ms2844 KiB
7Wrong answer0/34ms3108 KiB
8Wrong answer0/34ms3112 KiB
9Time limit exceeded0/2233ms4224 KiB
10Time limit exceeded0/2206ms4176 KiB
11Time limit exceeded0/2230ms4264 KiB
12Wrong answer0/2195ms4448 KiB
13Wrong answer0/2193ms4300 KiB
14Wrong answer0/2190ms4324 KiB
15Wrong answer0/2192ms4388 KiB
16Time limit exceeded0/2279ms3200 KiB
17Wrong answer0/2194ms4628 KiB
18Time limit exceeded0/2248ms4844 KiB
19Wrong answer0/2189ms4908 KiB
20Time limit exceeded0/2263ms3644 KiB
21Time limit exceeded0/2261ms3608 KiB
22Wrong answer0/3192ms5088 KiB
23Wrong answer0/3186ms5228 KiB
24Time limit exceeded0/3244ms3952 KiB