67882023-12-19 09:59:00madvirZenehallgatáscpp17Runtime error 19/50270ms64928 KiB
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int h[n+1], hossz=0;
    for(int i=1; i<=n; i++) {
        cin >> h[i];
        hossz+=h[i];
    }

    int p[hossz+1], x=1, y;
    for(int i=1; i<=n; i++) {
        y=x;
        while(y<x+h[i]) {
            p[y]=i;
            y++;
        }
        x=y;
    }
    p[0]=p[hossz];
    int z;
    for(int i=0; i<k-1; i++) {
        cin >> z;
        if(z>hossz) cout << p[z%hossz] << " ";
        else cout << p[z] << " ";
    }
    cin >> z;
    if(z>hossz) cout << p[z%hossz];
        else cout << p[z];

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base19/50
1Accepted0/03ms1876 KiB
2Runtime error0/059ms64928 KiB
3Accepted2/218ms41372 KiB
4Accepted2/214ms22204 KiB
5Accepted2/27ms6672 KiB
6Accepted3/34ms3400 KiB
7Accepted3/34ms3268 KiB
8Accepted3/34ms3336 KiB
9Runtime error0/259ms63748 KiB
10Runtime error0/259ms63512 KiB
11Runtime error0/259ms63488 KiB
12Runtime error0/254ms63356 KiB
13Runtime error0/254ms63364 KiB
14Runtime error0/254ms63336 KiB
15Runtime error0/254ms63104 KiB
16Runtime error0/254ms63096 KiB
17Runtime error0/254ms62916 KiB
18Time limit exceeded0/2254ms44532 KiB
19Time limit exceeded0/2237ms23456 KiB
20Accepted2/2179ms9100 KiB
21Accepted2/2178ms9080 KiB
22Time limit exceeded0/3270ms6020 KiB
23Time limit exceeded0/3259ms4964 KiB
24Time limit exceeded0/3254ms4980 KiB