65912023-12-12 17:11:58Huni136Zenehallgatáscpp17Accepted 50/50107ms6448 KiB
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

/*
Be:
3 2
2 4 3
6 10

KI:
2 1
*/



/*
Be:
5 3
3 2 7 8 1
10 50 20
Ki:
3 3 4
*/

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

KI: 1 5 4 6 6 6
*/


int main()
{
    int n,k;
    cin>>n>>k;

    vector<int> a(n), resz(n);
    for(int i=0;i<n;i++)
    {
        cin>>a.at(i);
        if (i==0)
            resz.at(i)=a.at(i);
        else
            resz.at(i)=resz.at(i-1)+a.at(i);
    }
    /*
    cout<<endl;
    for(int x:resz)
        cout<<x<<" ";
    */
    int teljes=resz.at(n-1);

    vector<int> kerdes(k), keresni(k);
    //cout<<endl;
    for(int i=0;i<k;i++)
    {
        cin>>kerdes.at(i);
        keresni.at(i)=kerdes.at(i)%teljes;
    }
    /*cout<<endl;
    for(int x:keresni)
        cout<<x<<" ";

    cout<<endl;
    */
    for(int x:keresni)
    {
        int bal=0, jobb=n-1;

        bool talalt=false;

        while (bal<=jobb && !talalt)
        {
            //cout<<"bal "<<bal<<" jobb "<<jobb<<" *** ";


            int kozepe=(bal+jobb)/2;
            if(bal+1==jobb)
              if(x<=resz.at(bal))
              {
                 cout<<bal+1<<" ";
                 talalt=true;
              }
              else
              {
                 cout<<jobb+1<<" ";
                 talalt=true;
              }
            else if(x<resz.at(kozepe))
                jobb=kozepe;
            else
                bal=kozepe;

        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1960 KiB
2Accepted0/0105ms4956 KiB
3Accepted2/24ms2184 KiB
4Accepted2/24ms2340 KiB
5Accepted2/24ms2552 KiB
6Accepted3/33ms2632 KiB
7Accepted3/33ms2636 KiB
8Accepted3/33ms2864 KiB
9Accepted2/2107ms5844 KiB
10Accepted2/2105ms5848 KiB
11Accepted2/2104ms5848 KiB
12Accepted2/2104ms5752 KiB
13Accepted2/2101ms5828 KiB
14Accepted2/2101ms5824 KiB
15Accepted2/2104ms6008 KiB
16Accepted2/2101ms5968 KiB
17Accepted2/2103ms6220 KiB
18Accepted2/298ms6292 KiB
19Accepted2/298ms6300 KiB
20Accepted2/297ms6448 KiB
21Accepted2/296ms6404 KiB
22Accepted3/397ms6404 KiB
23Accepted3/396ms6404 KiB
24Accepted3/396ms6400 KiB