120562024-11-26 20:28:49RRoliZenehallgatáscpp17Wrong answer 0/50300ms2404 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 << 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
base0/50
1Wrong answer0/01ms320 KiB
2Time limit exceeded0/0275ms2356 KiB
3Wrong answer0/24ms336 KiB
4Wrong answer0/24ms320 KiB
5Wrong answer0/24ms320 KiB
6Wrong answer0/34ms320 KiB
7Wrong answer0/34ms508 KiB
8Wrong answer0/34ms320 KiB
9Time limit exceeded0/2300ms2404 KiB
10Time limit exceeded0/2300ms2224 KiB
11Time limit exceeded0/2300ms2260 KiB
12Time limit exceeded0/2284ms2360 KiB
13Time limit exceeded0/2277ms2064 KiB
14Time limit exceeded0/2279ms2104 KiB
15Time limit exceeded0/2300ms2268 KiB
16Time limit exceeded0/2284ms2104 KiB
17Time limit exceeded0/2280ms2100 KiB
18Time limit exceeded0/2282ms2032 KiB
19Time limit exceeded0/2300ms2028 KiB
20Time limit exceeded0/2289ms2104 KiB
21Time limit exceeded0/2293ms2104 KiB
22Time limit exceeded0/3291ms2104 KiB
23Time limit exceeded0/3300ms2040 KiB
24Time limit exceeded0/3289ms2104 KiB