192202025-11-30 13:37:21szabelrZenehallgatáscpp17Time limit exceeded 15/50263ms1772 KiB
// zenehalllgatas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
ll binkeres(ll x, vector<ll>&zenek) {
    ll l = 1, r = zenek.size()-1;
    while (l < r) {
        ll mid = l + (r - l) / 2;
        if (x<=zenek[mid] and x>zenek[mid - 1])
            return mid;
        else if ( x <= zenek[mid - 1])
            r = mid - 1;
        else 
            l = mid + 1;
    }
}
int main()
{
    ll n, k,x;
    cin >> n >> k;
    vector<ll>zenek(n+2);
    zenek[0] = 0;
    for (ll i = 1; i <= n; i++)
    {
        cin >> x;
        zenek[i] = zenek[i - 1] + x;
    }
    for (ll i = 1; i <= k; i++) {
        cin >> x;
        if (x > zenek[n] ) {
            x = x % zenek[n];
        }
        if (x == 0) {
            cout << 1;
        }
        else
            cout<<binkeres(x, zenek)<<" ";
    }

}

// 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
base15/50
1Accepted0/01ms316 KiB
2Time limit exceeded0/0261ms1588 KiB
3Accepted2/23ms508 KiB
4Accepted2/23ms316 KiB
5Accepted2/23ms316 KiB
6Accepted3/33ms316 KiB
7Accepted3/33ms508 KiB
8Accepted3/33ms316 KiB
9Time limit exceeded0/2256ms1732 KiB
10Time limit exceeded0/2256ms1700 KiB
11Time limit exceeded0/2263ms1708 KiB
12Time limit exceeded0/2254ms1704 KiB
13Time limit exceeded0/2252ms1752 KiB
14Time limit exceeded0/2259ms1588 KiB
15Time limit exceeded0/2256ms1588 KiB
16Time limit exceeded0/2259ms1580 KiB
17Time limit exceeded0/2252ms1588 KiB
18Time limit exceeded0/2257ms1588 KiB
19Time limit exceeded0/2250ms1588 KiB
20Time limit exceeded0/2256ms1728 KiB
21Time limit exceeded0/2259ms1724 KiB
22Time limit exceeded0/3248ms1772 KiB
23Time limit exceeded0/3247ms1764 KiB
24Time limit exceeded0/3224ms1588 KiB