158212025-03-03 21:40:46rennZenehallgatáscpp17Wrong answer 0/5052ms1400 KiB
#include <bits/stdc++.h>
using namespace std;

#define GOTTAGOFAST cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);

int binkeres(int hossz[], int& dal, int& keres)
{
    static int bal, jobb, mid;
    bal = 0, jobb = dal;
    
    while(bal < jobb)
    {
        mid = bal + (jobb-bal)/2;

        if(hossz[mid] > keres)
            jobb = mid-1;
        else
            bal = mid+1;
    }
    
    return mid;
}

int main(){
    GOTTAGOFAST

    int dal, ido, curr;
    cin >> dal >> ido;

    int hossz[dal];
    cin >> hossz[0];
    for(int i = 1; i < dal; i++)
    {
        cin >> hossz[i];
        hossz[i] += hossz[i-1];
    }

    while(ido--)
    {
        cin >> curr;
        curr %= hossz[dal-1];
        curr = binkeres(hossz, dal, curr);
        cout << (curr ? curr : dal) << " ";
    }

}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/01ms512 KiB
2Wrong answer0/052ms1328 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/31ms316 KiB
7Wrong answer0/31ms388 KiB
8Wrong answer0/31ms316 KiB
9Wrong answer0/252ms1324 KiB
10Wrong answer0/250ms1400 KiB
11Wrong answer0/252ms1336 KiB
12Wrong answer0/252ms1212 KiB
13Wrong answer0/250ms1180 KiB
14Wrong answer0/250ms1308 KiB
15Wrong answer0/250ms1180 KiB
16Wrong answer0/250ms1308 KiB
17Wrong answer0/250ms1240 KiB
18Wrong answer0/250ms1380 KiB
19Wrong answer0/250ms1204 KiB
20Wrong answer0/248ms1332 KiB
21Wrong answer0/248ms1220 KiB
22Wrong answer0/348ms1180 KiB
23Wrong answer0/348ms1372 KiB
24Wrong answer0/348ms1368 KiB