124152024-12-17 13:41:51markfsibianZenehallgatáscpp17Time limit exceeded 0/50296ms1380 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/01ms512 KiB
2Time limit exceeded0/0254ms1340 KiB
3Wrong answer0/23ms320 KiB
4Wrong answer0/23ms320 KiB
5Wrong answer0/24ms320 KiB
6Wrong answer0/38ms320 KiB
7Wrong answer0/313ms320 KiB
8Wrong answer0/346ms320 KiB
9Time limit exceeded0/2256ms1380 KiB
10Time limit exceeded0/2263ms1180 KiB
11Time limit exceeded0/2263ms1336 KiB
12Time limit exceeded0/2254ms1244 KiB
13Time limit exceeded0/2252ms1276 KiB
14Time limit exceeded0/2257ms1200 KiB
15Time limit exceeded0/2256ms1336 KiB
16Time limit exceeded0/2252ms1336 KiB
17Time limit exceeded0/2256ms1336 KiB
18Time limit exceeded0/2250ms1332 KiB
19Time limit exceeded0/2256ms1260 KiB
20Time limit exceeded0/2279ms1336 KiB
21Time limit exceeded0/2286ms1224 KiB
22Time limit exceeded0/3296ms1348 KiB
23Time limit exceeded0/3282ms1080 KiB
24Time limit exceeded0/3277ms1200 KiB