120172024-11-25 09:19:04RRoliZenehallgatáscpp17Time limit exceeded 0/50261ms1768 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[e]) return e;
		return u;
	}
	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]++;
	}
	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
base0/50
1Accepted0/01ms320 KiB
2Time limit exceeded0/0250ms1592 KiB
3Wrong answer0/23ms320 KiB
4Wrong answer0/23ms320 KiB
5Wrong answer0/23ms416 KiB
6Wrong answer0/33ms320 KiB
7Wrong answer0/33ms320 KiB
8Wrong answer0/33ms320 KiB
9Time limit exceeded0/2261ms1756 KiB
10Time limit exceeded0/2252ms1768 KiB
11Time limit exceeded0/2257ms1740 KiB
12Time limit exceeded0/2248ms1592 KiB
13Time limit exceeded0/2256ms1564 KiB
14Time limit exceeded0/2247ms1616 KiB
15Time limit exceeded0/2254ms1716 KiB
16Time limit exceeded0/2246ms1692 KiB
17Time limit exceeded0/2254ms1592 KiB
18Time limit exceeded0/2243ms1760 KiB
19Time limit exceeded0/2243ms1592 KiB
20Time limit exceeded0/2248ms1592 KiB
21Time limit exceeded0/2250ms1592 KiB
22Time limit exceeded0/3243ms1528 KiB
23Time limit exceeded0/3244ms1764 KiB
24Time limit exceeded0/3218ms1720 KiB