84712024-01-17 11:42:09GervidZenehallgatáscpp17Time limit exceeded 0/50282ms8956 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	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];

		int left = 0, right = n - 1, mid = (left + right) >> 1;

		while (left < right && left != mid)
		{
			mid = (left + right) >> 1;

			if (sums[mid] < time)
			{
				left = mid;
			}
			else
			{
				if (sums[mid] > time)
				{
					right = mid;
				}
				else
				{
					left = mid, right = mid;
				}
			}
		}

		cout << left + 1 << ' ';
	}
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0234ms4272 KiB
3Wrong answer0/26ms3920 KiB
4Wrong answer0/24ms3800 KiB
5Wrong answer0/24ms4020 KiB
6Wrong answer0/34ms4140 KiB
7Wrong answer0/34ms4248 KiB
8Wrong answer0/34ms4300 KiB
9Wrong answer0/2195ms6780 KiB
10Time limit exceeded0/2225ms7760 KiB
11Time limit exceeded0/2212ms7900 KiB
12Time limit exceeded0/2224ms8004 KiB
13Time limit exceeded0/2273ms8212 KiB
14Time limit exceeded0/2209ms8340 KiB
15Time limit exceeded0/2264ms8476 KiB
16Time limit exceeded0/2209ms8704 KiB
17Time limit exceeded0/2266ms7692 KiB
18Wrong answer0/2179ms8956 KiB
19Time limit exceeded0/2206ms8812 KiB
20Time limit exceeded0/2218ms8908 KiB
21Time limit exceeded0/2254ms8908 KiB
22Time limit exceeded0/3282ms7708 KiB
23Time limit exceeded0/3216ms8936 KiB
24Time limit exceeded0/3257ms8068 KiB