192152025-11-30 13:26:24szabelrZenehallgatáscpp17Időlimit túllépés 6/50300ms1332 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) / 2;
        if (x == zenek[mid])
            return mid;
        else if (x<zenek[mid] and x>zenek[mid - 1])
            return mid;
        else if (x < zenek[mid] and x < zenek[mid - 1])
            r = mid - 1;
        else if (x > zenek[mid])
            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];
        }
        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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base6/50
1Elfogadva0/01ms544 KiB
2Időlimit túllépés0/0294ms1332 KiB
3Elfogadva2/23ms328 KiB
4Elfogadva2/23ms316 KiB
5Elfogadva2/23ms316 KiB
6Időlimit túllépés0/3300ms316 KiB
7Időlimit túllépés0/3300ms316 KiB
8Időlimit túllépés0/3300ms316 KiB
9Időlimit túllépés0/2284ms1200 KiB
10Időlimit túllépés0/2300ms1200 KiB
11Időlimit túllépés0/2300ms1196 KiB
12Időlimit túllépés0/2300ms1076 KiB
13Időlimit túllépés0/2282ms1076 KiB
14Időlimit túllépés0/2300ms1076 KiB
15Időlimit túllépés0/2300ms1196 KiB
16Időlimit túllépés0/2300ms1196 KiB
17Időlimit túllépés0/2287ms1076 KiB
18Időlimit túllépés0/2300ms1196 KiB
19Időlimit túllépés0/2300ms1196 KiB
20Időlimit túllépés0/2298ms1204 KiB
21Időlimit túllépés0/2284ms1268 KiB
22Időlimit túllépés0/3298ms1196 KiB
23Időlimit túllépés0/3300ms1076 KiB
24Időlimit túllépés0/3300ms1076 KiB