73602024-01-08 10:51:52szasztundeZenehallgatáscpp17Time limit exceeded 30/50270ms5292 KiB
#include <iostream>
#include <vector>
using namespace std;
vector <int> a;
int main()
{
    int n,k,x;
    cin>>n>>k;
    a.push_back(0);
    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];
        if (x<a[0]) cout<<1<<" ";
        else if(x>a[n-1]) cout<<n<<" ";
        else{
            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=kk+1;
                else u=kk-1;
            }
            cout<<jo<<" ";
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/50
1Accepted0/03ms1872 KiB
2Accepted0/0200ms3196 KiB
3Accepted2/24ms2432 KiB
4Accepted2/24ms2660 KiB
5Accepted2/24ms2688 KiB
6Accepted3/34ms2776 KiB
7Accepted3/34ms2832 KiB
8Accepted3/34ms2836 KiB
9Time limit exceeded0/2266ms2984 KiB
10Accepted2/2193ms4500 KiB
11Accepted2/2194ms4376 KiB
12Accepted2/2196ms4372 KiB
13Time limit exceeded0/2252ms3080 KiB
14Accepted2/2193ms4592 KiB
15Time limit exceeded0/2209ms4588 KiB
16Time limit exceeded0/2238ms3316 KiB
17Accepted2/2192ms4740 KiB
18Time limit exceeded0/2250ms4720 KiB
19Accepted2/2187ms4804 KiB
20Time limit exceeded0/2244ms5024 KiB
21Time limit exceeded0/2270ms3760 KiB
22Time limit exceeded0/3221ms5080 KiB
23Accepted3/3199ms5200 KiB
24Time limit exceeded0/3223ms5292 KiB