15682022-11-26 20:25:351478Zenehallgatáscpp11Wrong answer 0/50300ms4608 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 - 1;
}

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
1Wrong answer0/03ms1812 KiB
2Time limit exceeded0/0300ms2036 KiB
3Wrong answer0/24ms2276 KiB
4Wrong answer0/24ms2468 KiB
5Wrong answer0/24ms2544 KiB
6Wrong answer0/34ms2600 KiB
7Wrong answer0/34ms2624 KiB
8Wrong answer0/34ms2732 KiB
9Time limit exceeded0/2300ms2968 KiB
10Time limit exceeded0/2280ms3124 KiB
11Time limit exceeded0/2246ms3312 KiB
12Time limit exceeded0/2273ms3440 KiB
13Time limit exceeded0/2273ms3556 KiB
14Time limit exceeded0/2238ms3612 KiB
15Time limit exceeded0/2246ms3600 KiB
16Time limit exceeded0/2273ms3868 KiB
17Time limit exceeded0/2273ms3976 KiB
18Time limit exceeded0/2261ms4000 KiB
19Time limit exceeded0/2273ms4080 KiB
20Time limit exceeded0/2254ms4132 KiB
21Time limit exceeded0/2261ms4208 KiB
22Time limit exceeded0/3277ms4476 KiB
23Time limit exceeded0/3277ms4344 KiB
24Time limit exceeded0/3273ms4608 KiB