872021-01-10 18:06:00Babják PéterZenehallgatáscpp11Runtime error 0/5012ms3964 KiB
#include <iostream>
#include <algorithm>
#include<vector>
#define ll long long
using namespace std;

ll subsum[100000];
int f=-1;
int bins(int e,int v,int x)
{
    if(e>=v)
    {
        return v;
    }
    int mid=(e+v)/2;
    if(subsum[mid]<x)
    {
        bins(mid+1,v,x);
    }
    else
    {
        f=mid;
        bins(e,mid,x);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int  n,k;cin>>n>>k;
    short int t[n];
    ll sum=0;

    cin>>t[0];sum+=t[0];
    subsum[0]=t[0];
    for(int i=1;i<n;i++)
    {
        cin>>t[i];
        subsum[i]=subsum[i-1]+t[i];
    }
    for(int i=0;i<k;i++)
    {
        ll a;cin>>a;
        a=a%subsum[n-1];
        bins(0,n,a);
        cout<<f+1<<" ";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Runtime error0/02ms1860 KiB
2Runtime error0/010ms3872 KiB
3Runtime error0/22ms2036 KiB
4Runtime error0/21ms2040 KiB
5Runtime error0/21ms2040 KiB
6Runtime error0/32ms2048 KiB
7Runtime error0/31ms2048 KiB
8Runtime error0/31ms2044 KiB
9Runtime error0/29ms3904 KiB
10Runtime error0/29ms3908 KiB
11Runtime error0/29ms3904 KiB
12Runtime error0/29ms3904 KiB
13Runtime error0/28ms3964 KiB
14Runtime error0/28ms3860 KiB
15Runtime error0/29ms3888 KiB
16Runtime error0/29ms3900 KiB
17Runtime error0/212ms3868 KiB
18Runtime error0/28ms3904 KiB
19Runtime error0/28ms3904 KiB
20Runtime error0/28ms3936 KiB
21Runtime error0/28ms3900 KiB
22Runtime error0/38ms3876 KiB
23Runtime error0/37ms3924 KiB
24Runtime error0/38ms3912 KiB