66412023-12-14 17:28:12mmatedZenehallgatáscpp17Accepted 50/5057ms4992 KiB
#include <bits/stdc++.h>
using namespace std;
#define f(i,k,n) for(int i=k; i<n; i++)
#define ll long long
const int inf = INT_MAX;

void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    int x;
    cin>>x;
    a[0]=x;
    int mod=x;
    f(i,1,n)
    {
        cin>>x;
        mod+=x;
        a[i]=a[i-1]+x;
    }
    f(i,0,k)
    {
        cin>>x;
        x=x%mod;
        auto it=lower_bound(a,a+n,x);
        if(x==0)    cout<<n-1<<" ";
        else    cout<<it-a+1<<" ";
    }
    cout<<"\n";

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1896 KiB
2Accepted0/057ms3012 KiB
3Accepted2/23ms2304 KiB
4Accepted2/23ms2512 KiB
5Accepted2/23ms2604 KiB
6Accepted3/33ms2820 KiB
7Accepted3/33ms3032 KiB
8Accepted3/33ms3244 KiB
9Accepted2/257ms4360 KiB
10Accepted2/257ms4360 KiB
11Accepted2/257ms4616 KiB
12Accepted2/257ms4728 KiB
13Accepted2/256ms4860 KiB
14Accepted2/256ms4680 KiB
15Accepted2/256ms4676 KiB
16Accepted2/257ms4680 KiB
17Accepted2/256ms4688 KiB
18Accepted2/254ms4680 KiB
19Accepted2/256ms4932 KiB
20Accepted2/254ms4992 KiB
21Accepted2/254ms4980 KiB
22Accepted3/354ms4992 KiB
23Accepted3/354ms4900 KiB
24Accepted3/354ms4900 KiB