29122023-02-02 18:14:10UnluckYZenehallgatáscpp11Accepted 50/50112ms9916 KiB
#include <bits/stdc++.h>

using namespace std;

int main(){


    int n, k; cin >> n >> k;
    vector<int> v;
    vector<pair<int, int>> t, mego;
    long long mod = 0;

    for (int i = 0; i < n; i++){
        int x; cin >> x; v.push_back(x);
        mod += x;
    }

    for (int i = 0; i < k; i++){
        int x; cin >> x; t.push_back({x%mod, i});
    }

    sort(t.begin(), t.end());

    int most = 1, j = 0;

    for (int i = 0; i < n; i++){
        if (j == k) break;
        most += v[i];
        while (true){
            if (t[j].first < most){
                mego.push_back({t[j].second, i+1});
                j++;
                if (j == k) break;
            }
            else {
                break;
            }
            
        }
    } 

    sort(mego.begin(), mego.end());

    for (auto i : mego){
        cout << i.second << " ";
    }

    // 11 2222 333 11 2222 333

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1808 KiB
2Accepted0/0112ms7448 KiB
3Accepted2/24ms2236 KiB
4Accepted2/24ms2452 KiB
5Accepted2/24ms2668 KiB
6Accepted3/34ms2896 KiB
7Accepted3/34ms3108 KiB
8Accepted3/33ms3180 KiB
9Accepted2/2112ms8412 KiB
10Accepted2/2112ms8704 KiB
11Accepted2/2112ms8612 KiB
12Accepted2/2111ms8612 KiB
13Accepted2/2109ms8872 KiB
14Accepted2/2108ms8852 KiB
15Accepted2/2108ms9112 KiB
16Accepted2/2109ms9080 KiB
17Accepted2/2108ms9192 KiB
18Accepted2/2105ms9192 KiB
19Accepted2/2107ms9340 KiB
20Accepted2/2104ms9372 KiB
21Accepted2/2103ms9336 KiB
22Accepted3/3103ms9480 KiB
23Accepted3/3104ms9764 KiB
24Accepted3/3103ms9916 KiB