58622023-10-04 16:28:20KCsengeZenehallgatáscpp14Time limit exceeded 15/50300ms5096 KiB
#include <iostream>

using namespace std;
/*
3 2
2 4 3
6 10

5 3
3 2 7 8 1
10 50 20

8 6
10 2 7 15 20 30 2 4
100 40 200 170 80 60
*/

int main()
{
    int x=0, i,j,n,k;
    cin>>n>>k;
    int t[n], p[k],resz[n];
    for(i=0;i<n;i++)
    {
        cin>>t[i];
        x=t[i]+x;
        resz[i]=x;
    }
    for(i=0;i<k;i++)
    {
        cin>>p[i];
    }

    for(j=0;j<k;j++)
    { i=0;
      int szamol=1;
        if(p[j]%x==0)
        {
            cout<<n;
        }

        else if(p[j]<x)
        {
            while(p[j]>resz[i])
            {
                i++;
                szamol++;
            }
            cout<<szamol<<" ";
        }
        else
        {
            while(p[j]>x)
            {
                p[j]=p[j]-x;
            }
            while(p[j]>resz[i])
            {
                i++;
                szamol++;
            }
            cout<<szamol<<" ";
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Accepted0/03ms2020 KiB
2Time limit exceeded0/0300ms2620 KiB
3Accepted2/24ms2344 KiB
4Accepted2/24ms2168 KiB
5Accepted2/24ms2296 KiB
6Accepted3/38ms2536 KiB
7Accepted3/313ms2716 KiB
8Accepted3/346ms2852 KiB
9Time limit exceeded0/2270ms3256 KiB
10Time limit exceeded0/2273ms3516 KiB
11Time limit exceeded0/2261ms3736 KiB
12Time limit exceeded0/2270ms3912 KiB
13Time limit exceeded0/2277ms3884 KiB
14Time limit exceeded0/2273ms4160 KiB
15Time limit exceeded0/2282ms4376 KiB
16Time limit exceeded0/2277ms4480 KiB
17Time limit exceeded0/2273ms4464 KiB
18Time limit exceeded0/2282ms4564 KiB
19Time limit exceeded0/2273ms4620 KiB
20Time limit exceeded0/2264ms4824 KiB
21Time limit exceeded0/2280ms4908 KiB
22Time limit exceeded0/3277ms4960 KiB
23Time limit exceeded0/3268ms5036 KiB
24Time limit exceeded0/3282ms5096 KiB