185902025-10-28 11:35:37ubormaciZenehallgatáscpp17Time limit exceeded 23/50209ms1808 KiB
#include <iostream>
#include <algorithm> // for sort, mainly
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <array>
#include <string>
#include <cstdio>
#include <iterator>
#include <unordered_set>
#include <cstdint> // for int64_t, int32_t, etc
#include <queue>
#include <stack>
#include <deque>
#include <numeric> // gcd, lcm
#include <fstream>
#include <bitset> // for bitset
#include <iomanip>
#include <cassert> // for set with custom ordering
#include <type_traits> // for set with custom ordering
#include <utility> // for swap, forward, etc
using namespace std;

#pragma GCC optimize("O2")
// #pragma GCC optimize("O1","O2","O3","Ofast","unroll-loops")
// #pragma GCC target("sse","sse2","sse3","sse4.1","sse4.2","avx","avx2","fma")

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

/*

notes:

int64_t
stoi(string s) -> string to int
to_string() -> int (or else) to string

vector declaration:
vector<ll> v(n, 0)
vector<vector<ll>> v(n, vector<ll>(n, 0));

{if statement} ? {truth value} : {false value}

#ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif

std::lcm(ll a, ll b), std::gcd(int a, int b)

cout << fixed << setprecision(n);

set with custom ordering
set<ll, decltype(&cmp)> qu(cmp);

*/

typedef int64_t ll;

void solve() {

	ll n, k;
	cin >> n >> k;

	vector<ll> pref(n, 0);
	for(ll i = 0; i < n; i++) {
		ll len;
		cin >> len;
		pref[i] = len;
		if(i > 0) {
			pref[i] += pref[i-1];
		}		
	}

	ll tot = pref[n-1];

	for(ll qi = 0; qi < k; qi++) {
		ll qh;
		cin >> qh;

		if(qh % tot == 0) {
			cout << n << " ";
			continue;
		}else{
			qh %= tot;
		}

		ll ind = lower_bound(pref.begin(), pref.end(), qh) - pref.begin();
		cout << ind+1 << " ";
	}

}

int main()
{
	std::ios_base::sync_with_stdio(false);
	//cin.tie(nullptr);
	//cout.tie(nullptr);

	solve();

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base23/50
1Accepted0/01ms512 KiB
2Accepted0/0196ms1588 KiB
3Accepted2/23ms316 KiB
4Accepted2/23ms332 KiB
5Accepted2/23ms316 KiB
6Accepted3/33ms316 KiB
7Accepted3/33ms316 KiB
8Accepted3/33ms508 KiB
9Time limit exceeded0/2202ms1588 KiB
10Time limit exceeded0/2209ms1588 KiB
11Time limit exceeded0/2207ms1764 KiB
12Time limit exceeded0/2202ms1588 KiB
13Time limit exceeded0/2202ms1588 KiB
14Time limit exceeded0/2208ms1748 KiB
15Time limit exceeded0/2206ms1588 KiB
16Time limit exceeded0/2202ms1588 KiB
17Time limit exceeded0/2209ms1732 KiB
18Time limit exceeded0/2207ms1752 KiB
19Time limit exceeded0/2201ms1588 KiB
20Time limit exceeded0/2204ms1808 KiB
21Accepted2/2200ms1756 KiB
22Time limit exceeded0/3206ms1572 KiB
23Accepted3/3200ms1804 KiB
24Accepted3/3174ms1588 KiB