Problem p02689 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define boost                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout << #x << " " << x << endl;
#define d2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define d2i(x, y, i)                                                           \\
  cout << #x << i << " " << x << " " << #y << i << " " << y << endl;
#define all(v) v.begin(), v.end()
#define fr(i, l, r) for (ll i = l; i < r; i++)
#define mems(a, x) memset(a, x, sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x, y) push_back(make_pair(x, y))
#define mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
  ll n, m;
  cin >> n >> m;
  bool ver[n + 1];
  mems(ver, true);
  ll h[n + 1];
  fr(i, 1, n + 1) cin >> h[i];

  fr(i, 0, m) {
    ll u, v;
    cin >> u >> v;
    if (h[u] > h[v])
      ver[v] = false;
    else if (h[u] < h[v])
      ver[u] = false;
    else
      ver[u] = false, ver[v] = false;
  }
  ll c = 0;

  for (int i = 1; i <= n; i++) {
    if (ver[i])
      c++;
  }
  cout << c;
}
int main() {
  ll t = 1;
  //  cin>>t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define boost                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout << #x << " " << x << endl;
#define d2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define d2i(x, y, i)                                                           \\
  cout << #x << i << " " << x << " " << #y << i << " " << y << endl;
#define all(v) v.begin(), v.end()
#define fr(i, l, r) for (ll i = l; i < r; i++)
#define mems(a, x) memset(a, x, sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x, y) push_back(make_pair(x, y))
#define mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll N = 1e5 + 10;
vll g[N];
void solve() {
  ll n, m;
  cin >> n >> m;
  ll h[n + 1];
  for (int i = 1; i < n; i++) {
    cin >> h[i];
  }
  fr(i, 0, m) {
    ll u, v;
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  ll c = 0;

  for (int i = 1; i <= n; i++) {
    bool ok = true;
    // if(g[i].size()==0)
    // continue;
    for (ll x : g[i]) {
      if (h[i] <= h[x]) {
        ok = false;
        break;
      }
    }
    if (ok)
      c++;
  }
  cout << c;
}
int main() {
  ll t = 1;
  //  cin>>t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}