16472022-12-01 11:54:291478Zenehallgatáscpp11Time limit exceeded 0/50266ms5036 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 j;
}

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];
        cout << binarySearch(1, n, a) << " ";
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms2516 KiB
2Time limit exceeded0/0226ms2744 KiB
3Wrong answer0/24ms2964 KiB
4Wrong answer0/24ms3152 KiB
5Wrong answer0/24ms3356 KiB
6Wrong answer0/34ms3556 KiB
7Wrong answer0/34ms3632 KiB
8Wrong answer0/34ms3860 KiB
9Wrong answer0/2197ms4068 KiB
10Wrong answer0/2194ms4168 KiB
11Time limit exceeded0/2224ms3272 KiB
12Wrong answer0/2195ms4432 KiB
13Time limit exceeded0/2256ms4540 KiB
14Wrong answer0/2189ms4644 KiB
15Wrong answer0/2190ms4724 KiB
16Time limit exceeded0/2254ms4724 KiB
17Wrong answer0/2187ms4720 KiB
18Time limit exceeded0/2209ms4720 KiB
19Time limit exceeded0/2248ms4724 KiB
20Wrong answer0/2185ms4820 KiB
21Wrong answer0/2185ms4908 KiB
22Wrong answer0/3181ms4944 KiB
23Time limit exceeded0/3266ms3888 KiB
24Time limit exceeded0/3263ms5036 KiB