Submission details
Task:Lisäykset
Sender:Kuha
Submission time:2025-11-28 21:45:49 +0200
Language:C++ (C++17)
Status:READY
Result:53
Feedback
groupverdictscore
#1ACCEPTED20
#2ACCEPTED33
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s1, 2, 3details
#3ACCEPTED0.01 s1, 3details
#4ACCEPTED0.01 s1, 3details
#5ACCEPTED0.03 s1, 3details
#6ACCEPTED0.09 s2, 3details
#7ACCEPTED0.09 s3details
#8ACCEPTED0.09 s3details
#9ACCEPTED0.11 s3details
#10--3details
#11--3details

Code

#include <bits/stdc++.h>

using namespace std;

int cnt[1111111];

int main () {
    int n, m;
    cin>>n>>m;
    for (int i = 0; i < n; i++) {
        int x;
        cin>>x;
        cnt[x]++;
    }
    set<int> ne;
    for (int i = 0; i <= 1000000; i++) {
        if (cnt[i]) ne.insert(i);
    }
    for (int i = 0; i < m; i++) {
        int prev = 0;
        int previ = 0;
        int k;
        vector<int> ops;
        cin>>k;
        //cout<<"NEW "<<k<<endl;
        for (int i : ne) {
            //cout<<"i "<<i<<endl;
            if (previ + 1 != i) prev = 0;
            if (cnt[i] - prev >= k) {
                //cout<<"MOVE "<<i<<" "<<(k)<<endl;
                cnt[i] -= k;
                cnt[i + 1] += k;
                ops.push_back(i);
                ops.push_back(i + 1);
                break;
            } else {
                //cout<<"MOVE "<<i<<" "<<(cnt[i] - prev)<<endl;
                cnt[i + 1] += cnt[i] - prev;
                k -= cnt[i] - prev;
                int x = cnt[i];
                cnt[i] = prev;
                prev = x - prev;
                ops.push_back(i);
                ops.push_back(i + 1);
            }
            previ = i;
        }
        for (int i : ops) {
            if (cnt[i]) ne.insert(i);
            else ne.erase(i);
        }
    }
    for (int i = 0; i < 1111111; i++) {
        while (cnt[i]--) cout<<i<<" ";
    }
    cout<<endl;
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
1 1000
0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1000 

user output
1000 

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
1000 1000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
511 511 511 511 511 511 511 51...

user output
511 511 511 511 511 511 511 51...

Test 3

Group: 1, 3

Verdict: ACCEPTED

input
1000 1000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
495 495 495 495 495 495 495 49...

user output
495 495 495 495 495 495 495 49...

Test 4

Group: 1, 3

Verdict: ACCEPTED

input
1000 1000
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 ...

correct output
562 562 562 562 562 562 562 56...

user output
562 562 562 562 562 562 562 56...

Test 5

Group: 1, 3

Verdict: ACCEPTED

input
1000 1000
0 1 3 4 6 9 9 9 10 11 11 11 11...

correct output
997 997 997 997 997 998 998 99...

user output
997 997 997 997 997 998 998 99...

Test 6

Group: 2, 3

Verdict: ACCEPTED

input
100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
50033 50033 50033 50033 50033 ...

user output
50033 50033 50033 50033 50033 ...

Test 7

Group: 3

Verdict: ACCEPTED

input
100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
49996 49996 49996 49996 49996 ...

user output
49996 49996 49996 49996 49996 ...

Test 8

Group: 3

Verdict: ACCEPTED

input
100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
50057 50057 50057 50057 50057 ...

user output
50057 50057 50057 50057 50057 ...

Test 9

Group: 3

Verdict: ACCEPTED

input
100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
50536 50536 50536 50536 50536 ...

user output
50536 50536 50536 50536 50536 ...

Test 10

Group: 3

Verdict:

input
100000 100000
0 4 7 29 33 44 52 75 77 79 82 ...

correct output
100000 100001 100003 100023 10...

user output
(empty)

Test 11

Group: 3

Verdict:

input
100000 100000
1 12 14 16 49 59 59 63 68 73 8...

correct output
100001 100010 100012 100014 10...

user output
(empty)