Help me in solving HEAPEDU3 problem

Describe your issue

I’m trying to solve this problem and I think my solution is correct. It works for sample test cases, but I get a WA verdict on hidden test cases. AI says it’s correct as well. I can’t see what’s wrong with it. Here’s my solution:

#include <bits/stdc++.h>

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::cin.ignore(1, '\n');

    /*
      ======================================
        Write a program to perform the
        following operations:

        1) Initialize an array
        2) Given an integer N, perform N
           queries over this array.
        3) Given a query "+ x", insert x
           in your array.
        4) Given a query "-", remove the
           maximum element of the array.
        5) After each query print the maximum
           element left in the array.
      ======================================
    */
  std::priority_queue<int> heap;

  for (int n = 0 ; n < N; n += 1) {
    std::string query;
    std::getline(std::cin, query, '\n');
    int operand; char operation    = query[0];
    if (operation == '+') operand = std::stoi(query.substr(1, query.length() - 1));
    if (operation == '-') operand = 0;
    if (operation == '+') { heap.push(operand); }
    if (operation == '-') { heap.pop(); }

    if (!heap.empty()) std::cout << heap.top() << std::endl;

  }
  return 0;
}

Help me solve this please, I’ve spent hours thinking what might be wrong with the code but I have no clue anymore. I’ve tried it with C++17 and C++20. Clicking other people’s solutions give me an Error 403. And there’s no solution provided in the problem itself.

can you provide problem link

i have solved this problem
refer to this code

#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
using namespace std;

ll power(ll a, ll b) {
  ll res = 1;

  while (b) {
    if (b & 1) {
      res = res * a % mod;
    }

    b >>= 1;
    a = a * a % mod;
  }

  return res;
}

ll inv(ll a) {
  return power(a, mod - 2);
}

int main() {
    cin.tie(0)->sync_with_stdio(false);
	int t;cin>>t;
	priority_queue<int>pq;
	while(t--){
	    char c;
	    cin>>c;
	    if(c=='+'){
	        int x;cin>>x;
	        pq.push(x);
	    }
	    else pq.pop();
	    cout<<pq.top()<<endl;
	}
	cerr << "Time : " << 1000 * ((double)clock()) / CLOCKS_PER_SEC << "ms" << endl;
	return 0;
}

Thanks. I guess my WA has to do with input processing.