92432024-02-19 11:05:25GervidZenehallgatáscpp17Time limit exceeded 34/50259ms4908 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	iostream::sync_with_stdio(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
base34/50
1Accepted0/03ms2104 KiB
2Accepted0/0146ms2928 KiB
3Accepted2/24ms2272 KiB
4Accepted2/24ms2584 KiB
5Accepted2/24ms2588 KiB
6Accepted3/34ms2820 KiB
7Accepted3/34ms3020 KiB
8Accepted3/34ms3232 KiB
9Time limit exceeded0/2259ms3216 KiB
10Accepted2/2144ms4480 KiB
11Time limit exceeded0/2246ms4436 KiB
12Time limit exceeded0/2230ms4564 KiB
13Accepted2/2162ms4564 KiB
14Time limit exceeded0/2231ms4588 KiB
15Time limit exceeded0/2259ms3820 KiB
16Time limit exceeded0/2254ms3732 KiB
17Accepted2/2148ms4680 KiB
18Accepted2/2146ms4860 KiB
19Accepted2/2144ms4820 KiB
20Time limit exceeded0/2257ms4824 KiB
21Time limit exceeded0/2201ms4904 KiB
22Accepted3/3150ms4908 KiB
23Accepted3/3145ms4904 KiB
24Accepted3/3145ms4900 KiB