124142024-12-17 13:20:55markfsibianZenehallgatáscpp17Time limit exceeded 0/50296ms1340 KiB
#include <iostream>

using namespace std;

int v[100001], n, m;

int bins(int v[100001], int n, int t)
{
    while (t > v[n])
        t = t - v[n];
    int b = 1;
    int j = n;
    int k;
    int m = (b + j) / 2;
    while (b <= j)
    {
        k = (b + j) / 2;
        if (v[k] == t)
            return k;
        else if (v[k] > t)
            j = k - 1;
        else
            b = k + 1;
    }
    if (b > m)
        return b - 1;
    else
        return b;
}

int main()
{
    cin >> n >> m;
    int a;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a;
        v[i] = v[i - 1] + a;
    }
    for (int i = 1; i <= m; ++i)
    {
        cin >> a;
        cout << bins(v, n, a) << " ";
    }
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/01ms320 KiB
2Time limit exceeded0/0252ms1328 KiB
3Wrong answer0/24ms320 KiB
4Wrong answer0/24ms320 KiB
5Wrong answer0/23ms320 KiB
6Wrong answer0/38ms320 KiB
7Wrong answer0/313ms396 KiB
8Wrong answer0/346ms560 KiB
9Time limit exceeded0/2256ms1336 KiB
10Time limit exceeded0/2261ms1216 KiB
11Time limit exceeded0/2259ms1336 KiB
12Time limit exceeded0/2254ms1336 KiB
13Time limit exceeded0/2252ms1340 KiB
14Time limit exceeded0/2261ms1336 KiB
15Time limit exceeded0/2259ms1336 KiB
16Time limit exceeded0/2252ms1336 KiB
17Time limit exceeded0/2252ms1320 KiB
18Time limit exceeded0/2261ms1316 KiB
19Time limit exceeded0/2261ms1272 KiB
20Time limit exceeded0/2279ms1336 KiB
21Time limit exceeded0/2286ms1336 KiB
22Time limit exceeded0/3296ms1336 KiB
23Time limit exceeded0/3279ms1084 KiB
24Time limit exceeded0/3282ms1080 KiB