16532022-12-01 12:31:341478Zenehallgatáscpp11Time limit exceeded 0/50273ms5200 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())

const int nMax = 100000;
vector<int> prefixSum(nMax + 1);

int binarySearch(int i, int j, int val)
{
    int m;
    while (i < j)
    {
        m = i + (j - i) / 2;
        if (prefixSum[m] == val)
            return m;
        else if (prefixSum[m] > val)
        {
            j = m - 1;
        }
        else
        {
            i = m + 1;
        }
    }
    return i;
}

int main()
{
    //ifstream cin("be.txt");

    int n;
    cin >> n;

    int m;
    cin >> m;

    int a;

    for (int i = 1; i <= n; i++)
    {
        cin >> a;
        prefixSum[i] = prefixSum[i - 1] + a;
    }

    while (m--)
    {
        cin >> a;
        a %= prefixSum[n];

        if (a == 0)
            cout << n << " ";
        else
        {
            cout << binarySearch(1, n, a) << " ";
        }
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms2520 KiB
2Time limit exceeded0/0263ms1628 KiB
3Wrong answer0/24ms2940 KiB
4Wrong answer0/24ms2988 KiB
5Wrong answer0/24ms2988 KiB
6Wrong answer0/34ms3088 KiB
7Wrong answer0/34ms3336 KiB
8Wrong answer0/34ms3228 KiB
9Time limit exceeded0/2229ms3356 KiB
10Wrong answer0/2193ms3584 KiB
11Time limit exceeded0/2259ms2756 KiB
12Time limit exceeded0/2247ms3996 KiB
13Time limit exceeded0/2266ms3176 KiB
14Time limit exceeded0/2230ms3228 KiB
15Time limit exceeded0/2248ms4272 KiB
16Time limit exceeded0/2254ms3264 KiB
17Wrong answer0/2192ms4580 KiB
18Time limit exceeded0/2273ms4656 KiB
19Wrong answer0/2187ms4752 KiB
20Wrong answer0/2185ms4980 KiB
21Wrong answer0/2187ms5060 KiB
22Wrong answer0/3182ms5200 KiB
23Wrong answer0/3182ms4956 KiB
24Wrong answer0/3184ms4960 KiB