134282025-01-07 22:46:15csdavidZenehallgatáscpp17Accepted 50/50100ms3128 KiB
#include <iostream>
#include <algorithm>
using namespace std;

int n, q, x;

struct kerdes{
    int ido, ind;
};

bool alma(kerdes x123, kerdes y123){
    return x123.ido<y123.ido;
}

int main()
{
    long long hossz=0;
    cin >> n >> q;
    long long a[n];
    kerdes k[q];
    int megoldas[q];
    for(int i=0; i<n; i++){
        cin >> a[i];
        hossz+=a[i];
        a[i]=hossz;
    }
    hossz=a[n-1];
    for(int i=0; i<q; i++){
        cin >> x;
        if(x%hossz!=0) x=x%hossz;
        else{
            x=hossz;
        }
        k[i].ido=x;
        k[i].ind=i;
    }
    sort(k, k+q, alma);
    int j=0;
    for(int i=0; i<q; i++){
        while(k[i].ido>a[j]){
            j++;
        }
        megoldas[k[i].ind]=j+1;
    }
    for(auto& it:megoldas){
        cout << it << ' ';
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/0100ms2776 KiB
3Accepted2/22ms316 KiB
4Accepted2/22ms316 KiB
5Accepted2/22ms316 KiB
6Accepted3/32ms316 KiB
7Accepted3/32ms316 KiB
8Accepted3/32ms316 KiB
9Accepted2/2100ms2872 KiB
10Accepted2/2100ms2772 KiB
11Accepted2/298ms2908 KiB
12Accepted2/297ms2780 KiB
13Accepted2/297ms2792 KiB
14Accepted2/296ms2936 KiB
15Accepted2/294ms2868 KiB
16Accepted2/296ms2868 KiB
17Accepted2/294ms2868 KiB
18Accepted2/292ms2724 KiB
19Accepted2/292ms2872 KiB
20Accepted2/290ms2876 KiB
21Accepted2/290ms2868 KiB
22Accepted3/390ms2892 KiB
23Accepted3/389ms2720 KiB
24Accepted3/389ms3128 KiB