2102021-02-07 18:31:52kovacs.peter.18fZenehallgatáscpp11Time limit exceeded 15/50298ms4368 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 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 (auto& e : timeS) {
		cin >> e;
	}
	for (auto e : timeS) {
		cout << find(e % songS[N - 1], songS) + 1 << " ";
	}
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Accepted0/02ms1760 KiB
2Time limit exceeded0/0248ms2812 KiB
3Accepted2/22ms2540 KiB
4Accepted2/22ms2540 KiB
5Accepted2/22ms2540 KiB
6Accepted3/32ms2540 KiB
7Accepted3/32ms2544 KiB
8Accepted3/32ms2544 KiB
9Time limit exceeded0/2296ms3504 KiB
10Time limit exceeded0/2257ms4368 KiB
11Time limit exceeded0/2298ms4248 KiB
12Time limit exceeded0/2294ms4176 KiB
13Time limit exceeded0/2215ms4240 KiB
14Time limit exceeded0/2216ms4180 KiB
15Time limit exceeded0/2216ms4244 KiB
16Time limit exceeded0/2211ms4252 KiB
17Time limit exceeded0/2231ms4180 KiB
18Time limit exceeded0/2228ms4244 KiB
19Time limit exceeded0/2217ms4364 KiB
20Time limit exceeded0/2216ms4368 KiB
21Time limit exceeded0/2218ms4196 KiB
22Time limit exceeded0/3277ms4248 KiB
23Time limit exceeded0/3298ms4240 KiB
24Time limit exceeded0/3291ms4240 KiB