128592025-01-02 17:02:47BucsMateZenehallgatáscpp17Accepted 50/50103ms1784 KiB
#include <iostream>
#include <vector>
//#include <fstream>

using namespace std;
/*
ifstream input("input.in");
ofstream output("output.out");
*/
int dalKezdet[100001] = {};

int binKereses(int idopont, int N)
{
    int bal = 1, jobb = N;
    int kozep;
    while(bal < jobb){
        kozep = (bal + jobb + 1)/2;
        if(dalKezdet[kozep] <= idopont){
            bal = kozep;
        }
        else{
            jobb = kozep-1;
        }
    }
    return bal;
}

int main()
{
    int N, K;
    cin >> N >> K;
    dalKezdet[1] = 1;
    int temp;
    for(int i = 2; i <= N; i++){
        cin >> temp;
        dalKezdet[i] = dalKezdet[i-1] + temp;
    }
    cin >> temp;
    int hossz = dalKezdet[N] + temp - 1;

    int idopont;
    vector<int> megoldas(K);
    for(int i = 0; i < K; i++){
        cin >> idopont;
        idopont = (idopont - 1)%hossz + 1;
        megoldas[i] = binKereses(idopont, N);
    }
    for(int i = 0; i < K; i++){
        cout << megoldas[i] << " ";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms512 KiB
2Accepted0/0103ms1588 KiB
3Accepted2/22ms320 KiB
4Accepted2/22ms320 KiB
5Accepted2/22ms340 KiB
6Accepted3/32ms320 KiB
7Accepted3/32ms320 KiB
8Accepted3/32ms416 KiB
9Accepted2/2103ms1564 KiB
10Accepted2/2103ms1716 KiB
11Accepted2/2101ms1784 KiB
12Accepted2/2101ms1716 KiB
13Accepted2/298ms1720 KiB
14Accepted2/298ms1592 KiB
15Accepted2/298ms1716 KiB
16Accepted2/298ms1576 KiB
17Accepted2/297ms1760 KiB
18Accepted2/296ms1616 KiB
19Accepted2/296ms1672 KiB
20Accepted2/293ms1588 KiB
21Accepted2/293ms1592 KiB
22Accepted3/393ms1712 KiB
23Accepted3/393ms1744 KiB
24Accepted3/393ms1592 KiB