120572024-11-26 20:30:09RRoliZenehallgatáscpp17Time limit exceeded 15/50261ms1780 KiB
#include <bits/stdc++.h>
using namespace std;

int n, k, a[100001], p[100001];
int binker(int e, int u, int t) {
	if(u-e <= 1) {
		if(t >= p[u]) return u;
		return e;
	}
	int mid = (e+u)/2;
	if(t >= p[mid]) return binker(mid, u, t);
	return binker(e, mid-1, t);
}

int main() {
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		if(i < n) p[i+1] = p[i] + a[i];
		p[i]++;
	}
	cout << endl;
	for(int i = 0; i < k; i++) {
		int q;
		cin >> q;
		q %= p[n]+a[n]-1;
		if(q == 0) cout << n << ' ';
		else cout << binker(1, n, q) << ' ';
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/50
1Accepted0/01ms320 KiB
2Time limit exceeded0/0246ms1592 KiB
3Accepted2/23ms320 KiB
4Accepted2/23ms320 KiB
5Accepted2/23ms508 KiB
6Accepted3/33ms320 KiB
7Accepted3/33ms604 KiB
8Accepted3/33ms516 KiB
9Time limit exceeded0/2252ms1584 KiB
10Time limit exceeded0/2250ms1532 KiB
11Time limit exceeded0/2261ms1704 KiB
12Time limit exceeded0/2248ms1592 KiB
13Time limit exceeded0/2246ms1592 KiB
14Time limit exceeded0/2254ms1720 KiB
15Time limit exceeded0/2252ms1592 KiB
16Time limit exceeded0/2246ms1592 KiB
17Time limit exceeded0/2246ms1588 KiB
18Time limit exceeded0/2252ms1780 KiB
19Time limit exceeded0/2248ms1592 KiB
20Time limit exceeded0/2240ms1712 KiB
21Time limit exceeded0/2240ms1592 KiB
22Time limit exceeded0/3246ms1668 KiB
23Time limit exceeded0/3244ms1592 KiB
24Time limit exceeded0/3222ms1712 KiB