30582023-02-10 10:16:37tamasmarkZenehallgatáscpp17Runtime error 26/5064ms64904 KiB
#include <iostream>
#include <vector>

using namespace std;

struct adat
{
    long long kezd, veg;
};

long long n, k, i, a, b, j, h;
vector <int> x;
vector<long long>megold;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    h = 0;
    //x.resize(LLONG_MAX + 1);
    x.push_back(0);
    for (i = 1; i <= n; ++i)
    {
        cin >> a;
        for (j = 1; j <= a; ++j)
        {
            x.push_back(i);
        }
        h = h + a;
    }
    x.resize(h + 1);
    for (i = 1; i <= k; ++i)
    {
        cin >> a;
        if (a >= x.size())
        {
            a = a % h;
            //megold.push_back(x[a]);
            cout << x[a] << " ";
        }
        else
        {
            //megold.push_back(x[a]);
            cout << x[a] << " ";
        }
    }
    /*for (i = 0; i < megold.size(); ++i)
    {
        cout << megold[i] << " ";
    }*/
    return 0;
}
/*
3 2
2 4 3
6 30
*/
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/03ms1896 KiB
2Runtime error0/052ms64904 KiB
3Runtime error0/263ms64668 KiB
4Accepted2/227ms35500 KiB
5Accepted2/27ms7004 KiB
6Accepted3/33ms3532 KiB
7Accepted3/33ms3244 KiB
8Accepted3/33ms2916 KiB
9Runtime error0/263ms64188 KiB
10Runtime error0/261ms63972 KiB
11Runtime error0/250ms63736 KiB
12Runtime error0/257ms63492 KiB
13Runtime error0/252ms63468 KiB
14Runtime error0/252ms63220 KiB
15Runtime error0/263ms62992 KiB
16Runtime error0/263ms62984 KiB
17Runtime error0/264ms62756 KiB
18Runtime error0/257ms62532 KiB
19Runtime error0/257ms62536 KiB
20Accepted2/243ms12908 KiB
21Accepted2/246ms12876 KiB
22Accepted3/343ms12880 KiB
23Accepted3/335ms6672 KiB
24Accepted3/335ms6652 KiB