92422024-02-19 11:04:57GervidZenehallgatáscpp17Accepted 50/5096ms4932 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	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/03ms1816 KiB
2Accepted0/096ms2760 KiB
3Accepted2/24ms2216 KiB
4Accepted2/23ms2304 KiB
5Accepted2/23ms2432 KiB
6Accepted3/33ms2516 KiB
7Accepted3/33ms2632 KiB
8Accepted3/33ms2768 KiB
9Accepted2/296ms3432 KiB
10Accepted2/296ms3660 KiB
11Accepted2/294ms3876 KiB
12Accepted2/294ms3956 KiB
13Accepted2/292ms4084 KiB
14Accepted2/292ms4160 KiB
15Accepted2/292ms4292 KiB
16Accepted2/292ms4404 KiB
17Accepted2/290ms4620 KiB
18Accepted2/289ms4700 KiB
19Accepted2/289ms4796 KiB
20Accepted2/286ms4828 KiB
21Accepted2/286ms4844 KiB
22Accepted3/386ms4932 KiB
23Accepted3/386ms4932 KiB
24Accepted3/385ms4916 KiB