128612025-01-02 17:04:38BucsMateZenehallgatáscpp17Time limit exceeded 15/50261ms1368 KiB
#include <iostream>

using namespace std;

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, megoldas;
    for(int i = 0; i < K; i++){
        cin >> idopont;
        idopont = (idopont - 1)%hossz + 1;
        megoldas = binKereses(idopont, N);
        cout << megoldas << " ";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Accepted0/01ms320 KiB
2Time limit exceeded0/0254ms1328 KiB
3Accepted2/23ms320 KiB
4Accepted2/23ms320 KiB
5Accepted2/23ms320 KiB
6Accepted3/33ms320 KiB
7Accepted3/33ms320 KiB
8Accepted3/33ms508 KiB
9Time limit exceeded0/2261ms1300 KiB
10Time limit exceeded0/2256ms1320 KiB
11Time limit exceeded0/2259ms1332 KiB
12Time limit exceeded0/2254ms1348 KiB
13Time limit exceeded0/2259ms1260 KiB
14Time limit exceeded0/2252ms1368 KiB
15Time limit exceeded0/2256ms1336 KiB
16Time limit exceeded0/2256ms1336 KiB
17Time limit exceeded0/2250ms1328 KiB
18Time limit exceeded0/2248ms1184 KiB
19Time limit exceeded0/2252ms1188 KiB
20Time limit exceeded0/2244ms1340 KiB
21Time limit exceeded0/2252ms1332 KiB
22Time limit exceeded0/3252ms1220 KiB
23Time limit exceeded0/3245ms1340 KiB
24Time limit exceeded0/3222ms1336 KiB