2112021-02-07 18:57:04kovacs.peter.18fZenehallgatáscpp11Time limit exceeded 15/50298ms2320 KiB
#include <iostream>
#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 e + 1;
}

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/02ms1760 KiB
2Time limit exceeded0/0243ms2124 KiB
3Accepted2/22ms1856 KiB
4Accepted2/22ms1864 KiB
5Accepted2/22ms1860 KiB
6Accepted3/32ms1860 KiB
7Accepted3/32ms1860 KiB
8Accepted3/32ms1860 KiB
9Time limit exceeded0/2228ms2196 KiB
10Time limit exceeded0/2223ms2188 KiB
11Time limit exceeded0/2217ms2148 KiB
12Time limit exceeded0/2221ms2184 KiB
13Time limit exceeded0/2207ms2196 KiB
14Time limit exceeded0/2245ms2196 KiB
15Time limit exceeded0/2298ms2188 KiB
16Time limit exceeded0/2293ms2204 KiB
17Time limit exceeded0/2298ms2320 KiB
18Time limit exceeded0/2298ms2188 KiB
19Time limit exceeded0/2296ms2144 KiB
20Time limit exceeded0/2296ms2184 KiB
21Time limit exceeded0/2277ms2192 KiB
22Time limit exceeded0/3277ms2184 KiB
23Time limit exceeded0/3296ms2116 KiB
24Time limit exceeded0/3298ms2196 KiB