68012023-12-19 10:19:46madvirZenehallgatáscpp17Runtime error 32/50104ms64932 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, a[k];
    for(int i=0; i<k; i++) {
        cin >> a[i];
    }
    for(int i=0; i<k-1; i++) {
        if(a[i]>hossz) cout << p[a[i]%hossz] << " ";
        else cout << p[a[i]] << " ";
    }
    if(a[k-1]>hossz) cout << p[a[k-1]%hossz];
    else cout << p[a[k-1]];


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base32/50
1Accepted0/03ms1872 KiB
2Runtime error0/059ms64932 KiB
3Accepted2/221ms41372 KiB
4Accepted2/213ms22080 KiB
5Accepted2/24ms6392 KiB
6Accepted3/34ms2804 KiB
7Accepted3/34ms2588 KiB
8Accepted3/33ms2516 KiB
9Runtime error0/259ms64376 KiB
10Runtime error0/259ms64352 KiB
11Runtime error0/259ms64344 KiB
12Runtime error0/259ms64160 KiB
13Runtime error0/250ms63936 KiB
14Runtime error0/256ms63696 KiB
15Runtime error0/254ms63464 KiB
16Runtime error0/254ms63452 KiB
17Runtime error0/254ms63424 KiB
18Accepted2/2104ms44908 KiB
19Accepted2/2103ms44932 KiB
20Accepted2/282ms9956 KiB
21Accepted2/282ms9816 KiB
22Accepted3/382ms9936 KiB
23Accepted3/382ms7728 KiB
24Accepted3/379ms7352 KiB