15712022-11-26 20:40:301478Zenehallgatáscpp11Time limit exceeded 0/50300ms3908 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] + 1);
        cout << bS(pS, a) << " ";
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms1808 KiB
2Time limit exceeded0/0300ms2036 KiB
3Wrong answer0/24ms2212 KiB
4Wrong answer0/24ms2328 KiB
5Wrong answer0/24ms2456 KiB
6Wrong answer0/34ms2492 KiB
7Wrong answer0/34ms2492 KiB
8Wrong answer0/34ms2628 KiB
9Time limit exceeded0/2300ms2864 KiB
10Time limit exceeded0/2252ms3008 KiB
11Time limit exceeded0/2264ms3152 KiB
12Time limit exceeded0/2273ms3152 KiB
13Time limit exceeded0/2257ms3360 KiB
14Time limit exceeded0/2261ms3612 KiB
15Time limit exceeded0/2257ms3816 KiB
16Time limit exceeded0/2277ms3672 KiB
17Time limit exceeded0/2270ms3692 KiB
18Time limit exceeded0/2261ms3820 KiB
19Time limit exceeded0/2270ms3752 KiB
20Time limit exceeded0/2257ms3908 KiB
21Time limit exceeded0/2254ms3820 KiB
22Time limit exceeded0/3254ms3760 KiB
23Time limit exceeded0/3261ms3660 KiB
24Time limit exceeded0/3256ms3720 KiB