2092021-02-07 18:23:05kovacs.peter.18fZenehallgatáscpp11Time limit exceeded 15/50298ms2704 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
base15/50
1Accepted0/02ms1752 KiB
2Time limit exceeded0/0250ms2236 KiB
3Accepted2/22ms1992 KiB
4Accepted2/22ms1988 KiB
5Accepted2/22ms1988 KiB
6Accepted3/32ms1988 KiB
7Accepted3/32ms1988 KiB
8Accepted3/32ms1996 KiB
9Time limit exceeded0/2296ms2448 KiB
10Time limit exceeded0/2259ms2572 KiB
11Time limit exceeded0/2298ms2520 KiB
12Time limit exceeded0/2296ms2576 KiB
13Time limit exceeded0/2259ms2568 KiB
14Time limit exceeded0/2298ms2572 KiB
15Time limit exceeded0/2293ms2704 KiB
16Time limit exceeded0/2259ms2640 KiB
17Time limit exceeded0/2298ms2636 KiB
18Time limit exceeded0/2284ms2636 KiB
19Time limit exceeded0/2298ms2704 KiB
20Time limit exceeded0/2261ms2568 KiB
21Time limit exceeded0/2277ms2636 KiB
22Time limit exceeded0/3275ms2636 KiB
23Time limit exceeded0/3282ms2564 KiB
24Time limit exceeded0/3298ms2696 KiB