15702022-11-26 20:33:201478Zenehallgatáscpp11Time limit exceeded 15/50300ms4796 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
base15/50
1Accepted0/03ms1808 KiB
2Time limit exceeded0/0300ms1980 KiB
3Accepted2/24ms2224 KiB
4Accepted2/24ms2416 KiB
5Accepted2/24ms2624 KiB
6Accepted3/34ms2976 KiB
7Accepted3/34ms3040 KiB
8Accepted3/34ms3144 KiB
9Time limit exceeded0/2300ms3268 KiB
10Time limit exceeded0/2268ms3572 KiB
11Time limit exceeded0/2266ms3756 KiB
12Time limit exceeded0/2261ms3756 KiB
13Time limit exceeded0/2273ms3908 KiB
14Time limit exceeded0/2254ms3784 KiB
15Time limit exceeded0/2273ms3896 KiB
16Time limit exceeded0/2261ms4156 KiB
17Time limit exceeded0/2268ms4184 KiB
18Time limit exceeded0/2254ms4188 KiB
19Time limit exceeded0/2273ms4188 KiB
20Time limit exceeded0/2277ms4384 KiB
21Time limit exceeded0/2277ms4396 KiB
22Time limit exceeded0/3273ms4716 KiB
23Time limit exceeded0/3273ms4688 KiB
24Time limit exceeded0/3257ms4796 KiB