Submission details
Task:Lisäykset
Sender:Lieska
Submission time:2025-11-28 21:57:52 +0200
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:52:14: error: expected primary-expression before '>' token
   52 |             }>
      |              ^

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 = 0;
    int smallest = 0;
    for (int i=1; i<=n; ++i){
        int a;
        cin >> a;
        if (i==1) smallest = a;
        if (a != prev){
            diff[i] = a - prev;
            prev = a;
            if (i!=1) ch.insert(i);
        }
    }
    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";
}