electicode
АсосӣКурсҳоМанбаъҳоМасъалаҳо
Ҳамаи масъалаҳо
Khimio
Khayyam Finals 2025

Electi Courses - KhIMIO

2 сМаҳдудияти вақт
512 МБМаҳдудияти ҳофиза
Ҳамаи ҳалҳо

Тавсифи масъала

ElectiCode prepared MMM special courses for his students. There are NNN students in total, and the rating of the iii-th student is denoted by rir_iri​.

Farhod is going to teach exactly one student in each course. The process repeats exactly MMM times:

  • He chooses the student with the lowest current rating; if there are multiple such students, he selects the one with the smallest index.

Ҳал кардан мехоҳӣ?

Ворид шав, кодро ҳамин ҷо навис ва натиҷаро дарҳол бин.

Ворид шудан

electicode© 2026. Ҳамаи ҳуқуқҳо ҳифз шудаанд.

Намуд
  • He teaches this student special techniques, increasing their rating by SSS.
  • Student 111 became curious and started imagining QQQ different scenarios.
    In the iii-th scenario, he wonders what his final rating would be if his initial rating was qiq_iqi​.

    Input Format

    • The first line contains one integer T (1≤T≤103)T \ (1 \leq T \leq 10^3)T (1≤T≤103), the number of tests.
      • Then, for each test:

        • The first line contains four space-separated integers N,M,Q,SN, M, Q, SN,M,Q,S (1≤N,M,Q≤2⋅105,1≤S≤109)(1 \leq N, M, Q \leq 2 \cdot 10^5, 1 \leq S \leq 10^9)(1≤N,M,Q≤2⋅105,1≤S≤109).
        • The second line consists of NNN space-separated integers r1,r2,…,rNr_1, r_2, \ldots, r_Nr1​,r2​,…,rN​ .
        • The third line consists of QQQ space-separated integers q1,q2,…,qQq_1, q_2, \ldots, q_Qq1​,q2​,…,qQ​ .
      • The total sum of NNN in all tests doesn't exceed 2⋅1052 \cdot 10^52⋅105.

      • The total sum of MMM in all tests doesn't exceed 2⋅1052 \cdot 10^52⋅105.

      • The total sum of QQQ in all tests doesn't exceed 2⋅1052 \cdot 10^52⋅105.

    Output Format

    For each test, print one line consisting of QQQ space-separated integers.

    Scoring

    Let SNS_NSN​ be the total sum of NNN in all tests.

    SubtasksAdditional restrictionsPointsRequired Subtasks
    0Sample0-
    1SN≤200, Q=1S_N \leq 200, \ Q = 1SN​≤200, Q=110-
    2SN≤2 000, Q=1S_N \leq 2 \ 000, \ Q = 1SN​≤2 000, Q=1121
    3Q=1Q = 1Q=1131, 2
    4N≤2, ri=0N \leq 2, \ r_i = 0N≤2, ri​=013-
    5N≤200, ri=0N \leq 200, \ r_i = 0N≤200, ri​=0154
    6N≤2 000, ri=0N \leq 2 \ 000, \ r_i = 0N≤2 000, ri​=0174, 5
    7-200, 1, 2, 3, 4, 5, 6

    Мисолҳо

    Мисол 1
    Вуруд
    2 2 5 4 3 0 0 1 2 3 4 4 10 4 1 1 2 3 4 1 3 5 7
    Баромад
    7 8 9 10 5 6 6 7
    (0≤ri≤109)(0 \leq r_i \leq 10^9)(0≤ri​≤109)
    (0≤qi≤1018)(0 \leq q_i \leq 10^{18})
    (0≤qi​≤1018)