217262026-01-13 18:29:30PappMatyasZenehallgatáscpp17Time limit exceeded 24/50300ms1536 KiB
#include <iostream>
#include <vector>

using namespace std;

vector<int> v;

static int Find(int q)
{
	int s = 0;
	int e = v.size() - 1;
	int pos = v.size() / 2;
	while (v[pos - 1] >= q || v[pos] < q)
	{
		int n = (s + e) / 2;
		if (v[n] >= q)
		{
			e = n;
		}
		else
		{
			s = n;
		}
		pos = n;
		if (pos == 0 || pos == v.size() - 1)
		{
			break;
		}
	}
	return pos;
}

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

	int n, m, total = 0;
	cin >> n >> m;

	for (int i = 0; i < n; i++)
	{
		v.push_back(0);
		cin >> v[i];
		total += v[i];
		if (i != 0)
		{
			v[i] += v[i - 1];
		}
	}
	for (int i = 0; i < m; i++)
	{
		int x;
		cin >> x;
		x = x % total;
		if (x == 0)
		{
			x = total;
		}
		int j = Find(x);
		cout << j + 1 << " ";
	}
}
SubtaskSumTestVerdictTimeMemory
base24/50
1Accepted0/01ms508 KiB
2Time limit exceeded0/0284ms1076 KiB
3Time limit exceeded0/2284ms316 KiB
4Accepted2/21ms316 KiB
5Time limit exceeded0/2300ms316 KiB
6Time limit exceeded0/3298ms428 KiB
7Time limit exceeded0/3282ms316 KiB
8Time limit exceeded0/3282ms316 KiB
9Time limit exceeded0/2300ms948 KiB
10Accepted2/257ms1300 KiB
11Time limit exceeded0/2275ms948 KiB
12Accepted2/257ms1456 KiB
13Time limit exceeded0/2282ms1020 KiB
14Accepted2/256ms1372 KiB
15Accepted2/256ms1536 KiB
16Time limit exceeded0/2300ms948 KiB
17Accepted2/256ms1400 KiB
18Time limit exceeded0/2284ms1196 KiB
19Accepted2/254ms1308 KiB
20Accepted2/254ms1456 KiB
21Accepted2/254ms1484 KiB
22Accepted3/354ms1456 KiB
23Time limit exceeded0/3300ms948 KiB
24Accepted3/352ms1472 KiB