125492024-12-21 20:56:49nkbalintZenehallgatáscpp17Wrong answer 15/50287ms1732 KiB
#include <iostream>

using namespace std;

int N, K, v[100001], x[100001], a, i, b, j, kozep,c,p;

int main()
{
    cin >> N >> K;
    for (i = 1;i <= N;++i)
    {
        cin >> a;
        v[i] = v[i - 1] + a;
    }
    for (i = 1;i <= K;++i)
    {
        cin >> x[i];
    }
    for (i = 1;i <= K;++i)
    {
        b = 1;
        j = N;
        c = x[i];
        while (c > v[N]) c = c - v[K];
        while (b <= j)
        {
            kozep = (b + j) / 2;
            if (v[kozep] == c)
            {
                b=kozep;
                break;
            }
            else if (v[kozep] > c) j = kozep - 1;
            else b = kozep + 1;
        }
        if (v[b] >= c) cout << b << endl;
        else cout << b - 1 << endl;

    }
}


SubtaskSumTestVerdictTimeMemory
base15/50
1Wrong answer0/01ms512 KiB
2Time limit exceeded0/0247ms1592 KiB
3Accepted2/24ms320 KiB
4Accepted2/24ms508 KiB
5Accepted2/23ms320 KiB
6Accepted3/38ms320 KiB
7Accepted3/313ms320 KiB
8Accepted3/346ms408 KiB
9Time limit exceeded0/2261ms1732 KiB
10Time limit exceeded0/2250ms1628 KiB
11Time limit exceeded0/2250ms1632 KiB
12Time limit exceeded0/2244ms1592 KiB
13Time limit exceeded0/2256ms1592 KiB
14Time limit exceeded0/2246ms1648 KiB
15Time limit exceeded0/2246ms1552 KiB
16Time limit exceeded0/2241ms1532 KiB
17Time limit exceeded0/2256ms1592 KiB
18Time limit exceeded0/2246ms1584 KiB
19Time limit exceeded0/2250ms1612 KiB
20Time limit exceeded0/2280ms1592 KiB
21Time limit exceeded0/2287ms1528 KiB
22Time limit exceeded0/3280ms1592 KiB
23Time limit exceeded0/3282ms1592 KiB
24Time limit exceeded0/3287ms1592 KiB