76722024-01-10 12:02:25AblablablaZenehallgatáscpp17Accepted 50/5052ms4796 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    vector<int> prefix(n + 1, 0);
    for(int i = 1; i <= n; i++){
        cin >> prefix[i];
    }

    for(int i = 1; i <= n; i++){
        prefix[i] += prefix[i - 1];
    }

    for(int i = 0; i < m; i++){
        int akt;
        cin >> akt;
        akt %= prefix[n];

        int l = 0, r = n - 1;
        int valasz = 0;
        while(l <= r){
            int k = (l + r) / 2;

            if(prefix[k] < akt){
                valasz = k;
                l = k + 1;
            } else{
                r = k - 1;
            }
        }

        cout << valasz + 1 << " ";
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1864 KiB
2Accepted0/052ms2856 KiB
3Accepted2/23ms2244 KiB
4Accepted2/23ms2456 KiB
5Accepted2/23ms2668 KiB
6Accepted3/33ms2752 KiB
7Accepted3/33ms2880 KiB
8Accepted3/33ms2968 KiB
9Accepted2/252ms3916 KiB
10Accepted2/252ms3920 KiB
11Accepted2/252ms3916 KiB
12Accepted2/252ms3908 KiB
13Accepted2/250ms3904 KiB
14Accepted2/252ms3916 KiB
15Accepted2/252ms3912 KiB
16Accepted2/250ms4148 KiB
17Accepted2/252ms4116 KiB
18Accepted2/250ms4332 KiB
19Accepted2/250ms4340 KiB
20Accepted2/250ms4344 KiB
21Accepted2/250ms4596 KiB
22Accepted3/350ms4672 KiB
23Accepted3/348ms4572 KiB
24Accepted3/350ms4796 KiB