59352023-10-05 23:01:26AncsaZenehallgatáscpp11Accepted 50/50108ms7184 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/03ms1808 KiB
2Accepted0/0108ms5100 KiB
3Accepted2/23ms2228 KiB
4Accepted2/23ms2464 KiB
5Accepted2/24ms2660 KiB
6Accepted3/34ms2864 KiB
7Accepted3/33ms3096 KiB
8Accepted3/33ms3308 KiB
9Accepted2/2108ms6296 KiB
10Accepted2/2108ms6532 KiB
11Accepted2/2108ms6488 KiB
12Accepted2/2108ms6740 KiB
13Accepted2/2104ms7072 KiB
14Accepted2/2104ms6908 KiB
15Accepted2/2104ms6912 KiB
16Accepted2/2104ms6908 KiB
17Accepted2/2104ms6908 KiB
18Accepted2/2101ms6980 KiB
19Accepted2/2101ms6908 KiB
20Accepted2/298ms7168 KiB
21Accepted2/298ms7124 KiB
22Accepted3/3100ms7124 KiB
23Accepted3/398ms7124 KiB
24Accepted3/398ms7184 KiB