7112021-11-18 20:20:16Valaki2Zenehallgatáscpp14Accepted 50/5054ms25124 KiB
#include <bits/stdc++.h>
using namespace std;

int n, q;
vector<int> start;

void solve() {
    cin >> n >> q;
    start.assign(1 + n, 0);
    for(int i = 1; i <= n; i++) {
        int x = 0;
        cin >> x;
        start[i] = start[i - 1] + x;
    }
    int sum = start[n];
    while(q--) {
        int x;
        cin >> x;
        x--;
        x %= sum;
        cout << int(upper_bound(start.begin(), start.end(), x) - start.begin()) << " ";
    }
    cout << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1944 KiB
2Accepted0/050ms4276 KiB
3Accepted2/22ms3528 KiB
4Accepted2/21ms3540 KiB
5Accepted2/22ms3556 KiB
6Accepted3/32ms3580 KiB
7Accepted3/31ms3592 KiB
8Accepted3/32ms3608 KiB
9Accepted2/250ms5764 KiB
10Accepted2/250ms7204 KiB
11Accepted2/254ms8676 KiB
12Accepted2/252ms10080 KiB
13Accepted2/248ms11436 KiB
14Accepted2/252ms12780 KiB
15Accepted2/254ms14112 KiB
16Accepted2/248ms15472 KiB
17Accepted2/248ms16760 KiB
18Accepted2/250ms17996 KiB
19Accepted2/250ms19256 KiB
20Accepted2/248ms20428 KiB
21Accepted2/248ms21604 KiB
22Accepted3/352ms22788 KiB
23Accepted3/346ms23940 KiB
24Accepted3/354ms25124 KiB