123892024-12-16 12:59:10markfsibianZenehallgatáscpp17Wrong answer 0/50291ms1372 KiB
// fsdfsdsdf.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#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 b;
        else if (v[k] > t)
            j = k - 1;
        else
            b = k + 1;
    }
    if (b > m)
        return b;
    else
        return b - 1;
}

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
1Wrong answer0/01ms508 KiB
2Time limit exceeded0/0252ms1336 KiB
3Wrong answer0/23ms320 KiB
4Wrong answer0/24ms320 KiB
5Wrong answer0/23ms320 KiB
6Wrong answer0/38ms412 KiB
7Wrong answer0/313ms320 KiB
8Wrong answer0/346ms320 KiB
9Time limit exceeded0/2259ms1360 KiB
10Time limit exceeded0/2250ms1336 KiB
11Time limit exceeded0/2246ms1336 KiB
12Time limit exceeded0/2246ms1360 KiB
13Time limit exceeded0/2246ms1172 KiB
14Time limit exceeded0/2256ms1372 KiB
15Time limit exceeded0/2252ms1336 KiB
16Time limit exceeded0/2246ms1356 KiB
17Time limit exceeded0/2246ms1212 KiB
18Time limit exceeded0/2259ms1332 KiB
19Time limit exceeded0/2243ms1224 KiB
20Time limit exceeded0/2280ms1160 KiB
21Time limit exceeded0/2282ms1340 KiB
22Time limit exceeded0/3291ms1200 KiB
23Time limit exceeded0/3280ms1080 KiB
24Time limit exceeded0/3289ms1080 KiB