16482022-12-01 12:01:121478Zenehallgatáscpp11Wrong answer 4/50291ms5376 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) + 1 <<" ";
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Wrong answer0/03ms2520 KiB
2Time limit exceeded0/0291ms2736 KiB
3Accepted2/24ms2916 KiB
4Accepted2/24ms3116 KiB
5Wrong answer0/24ms3344 KiB
6Wrong answer0/34ms3544 KiB
7Wrong answer0/34ms3748 KiB
8Wrong answer0/34ms3956 KiB
9Time limit exceeded0/2256ms4028 KiB
10Wrong answer0/2194ms4284 KiB
11Time limit exceeded0/2275ms3236 KiB
12Time limit exceeded0/2261ms3324 KiB
13Time limit exceeded0/2256ms4380 KiB
14Wrong answer0/2193ms4476 KiB
15Time limit exceeded0/2273ms3540 KiB
16Time limit exceeded0/2214ms4624 KiB
17Time limit exceeded0/2275ms4848 KiB
18Time limit exceeded0/2275ms3804 KiB
19Time limit exceeded0/2243ms4912 KiB
20Time limit exceeded0/2232ms5052 KiB
21Wrong answer0/2199ms5152 KiB
22Time limit exceeded0/3238ms5180 KiB
23Wrong answer0/3184ms5376 KiB
24Wrong answer0/3193ms5356 KiB