2082021-02-07 18:21:47kovacs.peter.18fZenehallgatáscpp11Time limit exceeded 0/50298ms4856 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int find(int value, vector<int> v) {
	int b = 0;
	int e = v.size() - 1;
	do {
		int m = (b + e) / 2;
		if (v[m] == value) {
			return m;
		}
		if (v[m] > value) {
			e = m - 1;
		}
		else {
			b = m + 1;
		}
	} while (b != e);
	return b;
}

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

	int N, K;
	cin >> N >> K;
	vector<int> songS(N);
	cin >> songS[0];
	for (int i = 1; i < N; i++) {
		cin >> songS[i];
		songS[i] += songS[i - 1];
	}
	vector<int> timeS(K);
	for (int i = 0; i < K; i++) {
		int k;
		cin >> k;
		cout << find(k % songS[N - 1], songS) + 1 << " ";
	}
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/02ms1760 KiB
2Time limit exceeded0/0216ms2884 KiB
3Time limit exceeded0/2217ms1708 KiB
4Time limit exceeded0/2206ms1692 KiB
5Time limit exceeded0/2228ms1616 KiB
6Time limit exceeded0/3298ms1660 KiB
7Time limit exceeded0/3294ms1676 KiB
8Time limit exceeded0/3296ms1692 KiB
9Time limit exceeded0/2252ms3432 KiB
10Time limit exceeded0/2293ms4140 KiB
11Time limit exceeded0/2280ms4812 KiB
12Time limit exceeded0/2298ms4796 KiB
13Time limit exceeded0/2298ms4796 KiB
14Time limit exceeded0/2298ms4728 KiB
15Time limit exceeded0/2296ms4728 KiB
16Time limit exceeded0/2294ms4716 KiB
17Time limit exceeded0/2298ms4728 KiB
18Time limit exceeded0/2296ms4728 KiB
19Time limit exceeded0/2243ms4732 KiB
20Time limit exceeded0/2277ms4664 KiB
21Time limit exceeded0/2279ms4728 KiB
22Time limit exceeded0/3298ms4728 KiB
23Time limit exceeded0/3298ms4668 KiB
24Time limit exceeded0/3250ms4856 KiB