209762026-01-11 22:42:41hunzombiZenehallgatáscpp17Accepted 50/5052ms1740 KiB
#include <bits/stdc++.h>
using namespace std;

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

    int n, m;
    cin >> n >> m;
    vector<long long> end_time(n, 0);
    cin >> end_time[0];
    for (int i=1; i < n; i++) {
        cin >> end_time[i];
        end_time[i] += end_time[i - 1];
    }
    long long total = end_time[n - 1];
    for (int k = 0; k < m; k++) {
        long long target;
        cin >> target;
        target %= total;
        if (target == 0) target = total;
        int low = 0, high = n - 1;
        int ans = 0;
        while (low <= high) {
            int mid = low + (high - low) / 2;
            if (end_time[mid] < target) {
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }
        cout << low + 1 << ' ';
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/052ms1592 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms500 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted3/32ms316 KiB
9Accepted2/252ms1584 KiB
10Accepted2/252ms1556 KiB
11Accepted2/252ms1712 KiB
12Accepted2/252ms1588 KiB
13Accepted2/250ms1592 KiB
14Accepted2/250ms1588 KiB
15Accepted2/250ms1588 KiB
16Accepted2/250ms1736 KiB
17Accepted2/250ms1584 KiB
18Accepted2/250ms1620 KiB
19Accepted2/250ms1588 KiB
20Accepted2/248ms1740 KiB
21Accepted2/248ms1588 KiB
22Accepted3/350ms1588 KiB
23Accepted3/348ms1740 KiB
24Accepted3/348ms1588 KiB