150262025-02-11 12:08:06DhaneHaneZenehallgatáscpp17Időlimit túllépés 15/50257ms1392 KiB
// zenehalgatas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main()
{
    ll n, k; cin >> n >> k;
    vector <int> zsebi(n + 1);
    ll a;
    zsebi[0] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a;
        zsebi[i] = zsebi[i - 1] + a;
    }
    for (int i = 1; i <= k; ++i) {
        cin >> a;
        int b = 1, j=n;
        ll kereset = a % zsebi.back();
        while (b <= j) {
            int koz = (b+j) / 2;
            if (zsebi[koz] == kereset) {
                cout << koz << " ";
                break;
            }
            else if (zsebi[koz]>kereset) {
                j = koz - 1;
            }
            else {
                b = koz + 1;
            }
        }
        if (b > j) cout << b << " ";
        //cout << "k" << " ";
    }
}

// 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
base15/50
1Elfogadva0/01ms316 KiB
2Időlimit túllépés0/0250ms1332 KiB
3Elfogadva2/23ms316 KiB
4Elfogadva2/23ms316 KiB
5Elfogadva2/23ms316 KiB
6Elfogadva3/33ms316 KiB
7Elfogadva3/33ms316 KiB
8Elfogadva3/33ms316 KiB
9Időlimit túllépés0/2254ms1392 KiB
10Időlimit túllépés0/2257ms1312 KiB
11Időlimit túllépés0/2256ms1368 KiB
12Időlimit túllépés0/2250ms1332 KiB
13Időlimit túllépés0/2247ms1264 KiB
14Időlimit túllépés0/2254ms1332 KiB
15Időlimit túllépés0/2252ms1320 KiB
16Időlimit túllépés0/2256ms1316 KiB
17Időlimit túllépés0/2248ms1316 KiB
18Időlimit túllépés0/2254ms1320 KiB
19Időlimit túllépés0/2246ms1332 KiB
20Időlimit túllépés0/2250ms1384 KiB
21Időlimit túllépés0/2243ms1320 KiB
22Időlimit túllépés0/3243ms1340 KiB
23Időlimit túllépés0/3248ms1332 KiB
24Időlimit túllépés0/3218ms1332 KiB