121282024-12-03 12:55:34RRoliZenehallgatáscpp17Time limit exceeded 15/50254ms2540 KiB
#include <bits/stdc++.h>
using namespace std;

unsigned long long 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++) {
		unsigned long long 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/0245ms2304 KiB
3Accepted2/23ms320 KiB
4Accepted2/23ms564 KiB
5Accepted2/23ms360 KiB
6Accepted3/33ms320 KiB
7Accepted3/33ms320 KiB
8Accepted3/33ms320 KiB
9Time limit exceeded0/2254ms2424 KiB
10Time limit exceeded0/2254ms2360 KiB
11Time limit exceeded0/2245ms2492 KiB
12Time limit exceeded0/2244ms2456 KiB
13Time limit exceeded0/2245ms2540 KiB
14Time limit exceeded0/2250ms2484 KiB
15Time limit exceeded0/2250ms2536 KiB
16Time limit exceeded0/2241ms2360 KiB
17Time limit exceeded0/2241ms2484 KiB
18Time limit exceeded0/2241ms2484 KiB
19Time limit exceeded0/2243ms2520 KiB
20Time limit exceeded0/2238ms2360 KiB
21Time limit exceeded0/2238ms2368 KiB
22Time limit exceeded0/3246ms2512 KiB
23Time limit exceeded0/3245ms2508 KiB
24Time limit exceeded0/3214ms2360 KiB