124162024-12-17 13:46:02markfsibianZenehallgatáscpp17Time limit exceeded 0/50256ms1384 KiB
#include <iostream>

using namespace std;

int v[100001], n, m;

int bins(int v[100001], int n, int t)
{
    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/01ms508 KiB
2Time limit exceeded0/0246ms1344 KiB
3Wrong answer0/23ms320 KiB
4Wrong answer0/23ms332 KiB
5Wrong answer0/23ms320 KiB
6Wrong answer0/33ms320 KiB
7Wrong answer0/33ms320 KiB
8Wrong answer0/33ms320 KiB
9Time limit exceeded0/2256ms1336 KiB
10Time limit exceeded0/2250ms1176 KiB
11Time limit exceeded0/2252ms1324 KiB
12Time limit exceeded0/2246ms1336 KiB
13Time limit exceeded0/2250ms1384 KiB
14Time limit exceeded0/2250ms1336 KiB
15Time limit exceeded0/2246ms1336 KiB
16Time limit exceeded0/2244ms1224 KiB
17Time limit exceeded0/2252ms1336 KiB
18Time limit exceeded0/2243ms1336 KiB
19Time limit exceeded0/2248ms1140 KiB
20Time limit exceeded0/2239ms1336 KiB
21Time limit exceeded0/2246ms1340 KiB
22Time limit exceeded0/3239ms1220 KiB
23Time limit exceeded0/3245ms1336 KiB
24Time limit exceeded0/3216ms1336 KiB