Submission details
Task:Lisäykset
Sender:Lieska
Submission time:2025-11-28 22:19:29 +0200
Language:C++ (C++20)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED20
#2ACCEPTED33
#3ACCEPTED47
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3details
#2ACCEPTED0.00 s1, 2, 3details
#3ACCEPTED0.00 s1, 3details
#4ACCEPTED0.00 s1, 3details
#5ACCEPTED0.00 s1, 3details
#6ACCEPTED0.03 s2, 3details
#7ACCEPTED0.04 s3details
#8ACCEPTED0.04 s3details
#9ACCEPTED0.04 s3details
#10ACCEPTED0.10 s3details
#11ACCEPTED0.11 s3details

Code

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int diff[101010];
set<int> ch;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int prev = -1;
    int smallest = 0;
    for (int i=1; i<=n; ++i){
        int a;
        cin >> a;
        if (i==1) smallest = a;
        else{
            diff[i] = a - prev;
            if (a != prev) ch.insert(i);
        }
        prev = a;
    }
    ch.insert(n+1); // To avoid that it == ch.end() below.
    for (int i=1; i<=m; ++i){
        
        int k;
        cin >> k;
        auto it = ch.upper_bound(k);
        if (*it == k+1){
            diff[k+1]--;
            if (diff[k+1]==0){
                if (*it <= n) ch.erase(*it); // If so that we don't erase n+1.
            }
            smallest++;
        }
        else {
            auto ite = ch.begin();
            int b;
            int next = *it;
            if (*ite != *it) {
                smallest++;
                it--;
                b = k - *it + 1;
                diff[*it]--;
                if (diff[*it]==0 && *it <= n) ch.erase(*it);
            }
            else{
                b = k;    
            }
            diff[next]--;
            diff[next - b]=1;
            if (diff[next]==0 && next <= n) ch.erase(next);
            ch.insert(next-b);
        }
        /*
        cout << "here " << i << " " << k << " " << smallest << "\n";
        for (int j=1; j<=n; ++j) cout << diff[j] << " ";
        cout << "\n";
        for (auto u:ch) cout << u << " ";
        cout << "\n";
        */
    }
    int curr = smallest;
    for (int i=1; i<=n; ++i){
        curr+=diff[i];
        cout << curr << " ";
    }
    cout << "\n";
}

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: ACCEPTED

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

correct output
100000 100001 100003 100023 10...

user output
100000 100001 100003 100023 10...

Test 11

Group: 3

Verdict: ACCEPTED

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

correct output
100001 100010 100012 100014 10...

user output
100001 100010 100012 100014 10...