15692022-11-26 20:32:341478Zenehallgatáscpp11Runtime error 0/503ms4528 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int bS(vector<int> pS, int val)
{
    int i = 1, j = pS.size(), m;
    while (i <= j)
    {
        m = i + (j - i) / 2;
        if (pS[m] == val)
        {
            return m;
        }
        else if (pS[m] < val)
        {
            i = m + 1;
        }
        else
        {
            j = m - 1;
        }
    }
    return i;
}

int main()
{
    ifstream cin("be.txt");
    int n, m;
    cin >> n >> m;
    vector<int> pS(n + 1);
    for (int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        pS[i] = pS[i - 1] + a;
    }
    for (int i = 1; i <= m; i++)
    {
        int a;
        cin >> a;
        a = a % pS[n];
        cout << bS(pS, a) << " ";
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Runtime error0/03ms1844 KiB
2Runtime error0/02ms2036 KiB
3Runtime error0/22ms2316 KiB
4Runtime error0/22ms2520 KiB
5Runtime error0/22ms2840 KiB
6Runtime error0/32ms2788 KiB
7Runtime error0/32ms3040 KiB
8Runtime error0/32ms3244 KiB
9Runtime error0/22ms3528 KiB
10Runtime error0/22ms3848 KiB
11Runtime error0/22ms3680 KiB
12Runtime error0/22ms3516 KiB
13Runtime error0/22ms3948 KiB
14Runtime error0/22ms4040 KiB
15Runtime error0/22ms3916 KiB
16Runtime error0/22ms3924 KiB
17Runtime error0/22ms4120 KiB
18Runtime error0/22ms4280 KiB
19Runtime error0/22ms4268 KiB
20Runtime error0/22ms4312 KiB
21Runtime error0/22ms4368 KiB
22Runtime error0/32ms4228 KiB
23Runtime error0/32ms4528 KiB
24Runtime error0/32ms4244 KiB