17442022-12-02 13:41:521478Zenehallgatáscpp11Accepted 50/5050ms5652 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long i, n, m, a;

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

    cin >> n >> m;

    vector<long long> prefixSum(n + 1);

    for (i = 1; i <= n; ++i)
    {
        cin >> prefixSum[i];
        prefixSum[i] += prefixSum[i - 1];
    }

    for (i = 1; i <= m; ++i)
    {
        cin >> a;

        a = a % prefixSum[n];

        cout << lower_bound(prefixSum.begin() + 1, prefixSum.end(), a) - prefixSum.begin() << " ";
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/050ms3536 KiB
3Accepted2/23ms2328 KiB
4Accepted2/23ms2628 KiB
5Accepted2/23ms2684 KiB
6Accepted3/33ms2896 KiB
7Accepted3/32ms3096 KiB
8Accepted3/32ms3296 KiB
9Accepted2/250ms4772 KiB
10Accepted2/250ms4968 KiB
11Accepted2/250ms4976 KiB
12Accepted2/250ms5176 KiB
13Accepted2/250ms5176 KiB
14Accepted2/250ms5280 KiB
15Accepted2/248ms5280 KiB
16Accepted2/250ms5280 KiB
17Accepted2/250ms5272 KiB
18Accepted2/248ms5280 KiB
19Accepted2/248ms5268 KiB
20Accepted2/248ms5276 KiB
21Accepted2/248ms5444 KiB
22Accepted3/348ms5448 KiB
23Accepted3/348ms5648 KiB
24Accepted3/348ms5652 KiB