124012024-12-16 15:45:48ruffbrigiZenehallgatáscpp17Wrong answer 24/5054ms1784 KiB
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k,x,kk,e,u,ok;
    cin>>n;
    cin>>k;
    long long t[n];
    cin>>t[0];
    for(int i=1;i<=n-1;i++)
    {
        cin>>t[i];
        t[i]+=t[i-1];
    }
    for(int j=0;j<=k-1;j++)
    {
        cin>>x;
        x=x%t[n-1];
        if(x<=t[0]) cout<<1<<" ";
        else if(x>t[n-2]) cout<<n;
            else {int e=1,u=n;

                ok=0;
                while(e<=u && !ok)
                {
                    kk=(e+u)/2;
                if (x>t[kk] && x<=t[kk+1]) ok=kk+1;
                else if (x>t[kk-1] && x<=t[kk]) ok=kk;
                    else if(x<t[kk]) u=kk-1;
                        else if (x>t[kk]) e=kk+1;
                }

            cout<<ok+1<<" ";
            }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base24/50
1Accepted0/01ms508 KiB
2Wrong answer0/054ms1592 KiB
3Wrong answer0/22ms320 KiB
4Accepted2/22ms320 KiB
5Wrong answer0/21ms320 KiB
6Wrong answer0/31ms320 KiB
7Wrong answer0/31ms392 KiB
8Wrong answer0/31ms320 KiB
9Wrong answer0/254ms1728 KiB
10Accepted2/254ms1592 KiB
11Wrong answer0/254ms1616 KiB
12Accepted2/254ms1772 KiB
13Wrong answer0/254ms1592 KiB
14Accepted2/254ms1720 KiB
15Accepted2/254ms1704 KiB
16Wrong answer0/254ms1592 KiB
17Accepted2/254ms1776 KiB
18Wrong answer0/254ms1640 KiB
19Accepted2/252ms1752 KiB
20Accepted2/252ms1592 KiB
21Accepted2/252ms1692 KiB
22Accepted3/352ms1592 KiB
23Wrong answer0/352ms1784 KiB
24Accepted3/352ms1592 KiB