92412024-02-19 11:00:20GervidZenehallgatáscpp17Accepted 50/5052ms5068 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	iostream::sync_with_stdio(0);
	cin.tie(0);
	int n, k, i, j, temp, time;
	cin >> n >> k;

	vector<int> sums(n);
	cin >> sums[0];

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

	for (i = 0; i < k; i++)
	{
		cin >> time;

		time %= sums[n - 1];

		auto x = upper_bound(sums.begin(), sums.end(), time);

		cout << x - sums.begin() - ((x - (x != sums.begin())).operator*() == time) + 1 << ' ';
	}
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/050ms2880 KiB
3Accepted2/23ms2300 KiB
4Accepted2/23ms2332 KiB
5Accepted2/23ms2460 KiB
6Accepted3/33ms2676 KiB
7Accepted3/33ms2888 KiB
8Accepted3/33ms3100 KiB
9Accepted2/250ms4132 KiB
10Accepted2/250ms4336 KiB
11Accepted2/252ms4416 KiB
12Accepted2/250ms4548 KiB
13Accepted2/250ms4556 KiB
14Accepted2/250ms4568 KiB
15Accepted2/250ms4588 KiB
16Accepted2/250ms4552 KiB
17Accepted2/250ms4600 KiB
18Accepted2/248ms4580 KiB
19Accepted2/248ms4820 KiB
20Accepted2/248ms4812 KiB
21Accepted2/248ms5032 KiB
22Accepted3/348ms5020 KiB
23Accepted3/348ms5068 KiB
24Accepted3/348ms5056 KiB