29182023-02-03 12:30:36tamasmarkZenehallgatáscpp17Runtime error 26/50155ms64904 KiB
// zenehalgatas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#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 = 1;
    for (i = 1; i <= n; ++i)
    {
        cin >> a;
        for (j = 1; j <= a; ++j)
        {
            x.push_back(i);
        }
    }
    for (i = 1; i <= k; ++i)
    {
        cin >> a;
        a = a - 1;
        if (a > x.size()-1)
        {
            while (a > x.size()-1)
            {
                a = a - x.size();
            }
            megold.push_back(x[a]);
        }
        else 
        {
            megold.push_back(x[a]);
        }
    }
    for (i = 0; i < megold.size(); ++i)
    {
        cout << megold[i] << " ";
    }
    return 0;
}
/*
3 2
2 4 3
6 10

*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base26/50
1Accepted0/03ms1888 KiB
2Runtime error0/064ms64904 KiB
3Runtime error0/252ms64604 KiB
4Accepted2/232ms35544 KiB
5Accepted2/27ms6792 KiB
6Accepted3/38ms3500 KiB
7Accepted3/313ms3424 KiB
8Accepted3/346ms3208 KiB
9Runtime error0/252ms63756 KiB
10Runtime error0/250ms63644 KiB
11Runtime error0/263ms63620 KiB
12Runtime error0/261ms63384 KiB
13Runtime error0/252ms63144 KiB
14Runtime error0/263ms62916 KiB
15Runtime error0/264ms62820 KiB
16Runtime error0/264ms62808 KiB
17Runtime error0/254ms62608 KiB
18Runtime error0/268ms62616 KiB
19Runtime error0/268ms62460 KiB
20Accepted2/286ms12872 KiB
21Accepted2/290ms13140 KiB
22Accepted3/386ms13132 KiB
23Accepted3/3131ms9824 KiB
24Accepted3/3155ms9476 KiB