30572023-02-10 10:05:50tamasmarkZenehallgatáscpp17Runtime error 26/5064ms64872 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())
        {
            while (a >= x.size())
            {
                a = a % (x.size() - 1);
            }
            //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 10
*/
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/03ms1892 KiB
2Runtime error0/054ms64872 KiB
3Runtime error0/250ms64636 KiB
4Accepted2/227ms35520 KiB
5Accepted2/27ms7036 KiB
6Accepted3/33ms3692 KiB
7Accepted3/33ms3616 KiB
8Accepted3/33ms3632 KiB
9Runtime error0/250ms63452 KiB
10Runtime error0/250ms63220 KiB
11Runtime error0/250ms63212 KiB
12Runtime error0/250ms63208 KiB
13Runtime error0/250ms63104 KiB
14Runtime error0/250ms63064 KiB
15Runtime error0/250ms63076 KiB
16Runtime error0/264ms62844 KiB
17Runtime error0/254ms62676 KiB
18Runtime error0/254ms62664 KiB
19Runtime error0/257ms62668 KiB
20Accepted2/241ms12800 KiB
21Accepted2/241ms12708 KiB
22Accepted3/345ms12644 KiB
23Accepted3/335ms6472 KiB
24Accepted3/334ms6536 KiB