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

// created by mtnshh

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

#define ll long long
#define ld long double

#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repb(i, a, b) for (ll i = a; i >= b; i--)

#define err() cout << "==================================" << endl;
#define errA(A)                                                                \\
  for (auto i : A)                                                             \\
    cout << i << " ";                                                          \\
  cout << endl;
#define err1(a) cout << #a << " " << a << endl
#define err2(a, b) cout << #a << " " << a << " " << #b << " " << b << endl
#define err3(a, b, c)                                                          \\
  cout << #a << " " << a << " " << #b << " " << b << " " << #c << " " << c     \\
       << endl
#define err4(a, b, c, d)                                                       \\
  cout << #a << " " << a << " " << #b << " " << b << " " << #c << " " << c     \\
       << " " << #d << " " << d << endl

#define pb push_back
#define all(A) A.begin(), A.end()
#define allr(A) A.rbegin(), A.rend()
#define ft first
#define sd second

#define pll pair<ll, ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>

#define endl "\\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll N = 100005;

void solve() {
  ll n, m;
  cin >> n >> m;
  ll H[n + 1];
  ll A[n + 1];
  rep(i, 1, n + 1) A[i] = 1;
  rep(i, 1, n + 1) cin >> H[i];
  rep(i, 0, m) {
    ll u, v;
    cin >> u >> v;
    if (H[u] >= H[v])
      A[v] = 0;
    if (H[v] >= H[u])
      A[u] = 0;
  }
  ll cnt = 0;
  // rep(i,1,n+1)    cout<<A[i]<<" ";cout<<endl;
  rep(i, 1, n + 1) if (A[i]) cnt++;
  cout << cnt << endl;
  return;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll no;
  // cin>>no;
  no = 1;
  while (no--) {
    solve();
  }
  return 0;
}

Error: WA

Fixed submission:

// created by mtnshh

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

#define ll long long
#define ld long double

#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repb(i, a, b) for (ll i = a; i >= b; i--)

#define err() cout << "==================================" << endl;
#define errA(A)                                                                \\
  for (auto i : A)                                                             \\
    cout << i << " ";                                                          \\
  cout << endl;
#define err1(a) cout << #a << " " << a << endl
#define err2(a, b) cout << #a << " " << a << " " << #b << " " << b << endl
#define err3(a, b, c)                                                          \\
  cout << #a << " " << a << " " << #b << " " << b << " " << #c << " " << c     \\
       << endl
#define err4(a, b, c, d)                                                       \\
  cout << #a << " " << a << " " << #b << " " << b << " " << #c << " " << c     \\
       << " " << #d << " " << d << endl

#define pb push_back
#define all(A) A.begin(), A.end()
#define allr(A) A.rbegin(), A.rend()
#define ft first
#define sd second

#define pll pair<ll, ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>

#define endl "\\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll N = 100005;

void solve() {
  ll n, m;
  cin >> n >> m;
  ll H[n];
  ll A[n + 1];
  rep(i, 1, n + 1) A[i] = 1;
  rep(i, 0, m) {
    ll u, v;
    cin >> u >> v;
    if (H[u] > H[v])
      A[v] = 0;
    if (H[v] > H[u])
      A[u] = 0;
  }
  ll cnt = 0;
  // rep(i,1,n+1)    cout<<A[i]<<" ";cout<<endl;
  rep(i, 1, n + 1) if (A[i]) cnt++;
  cout << cnt << endl;
  return;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll no;
  // cin>>no;
  no = 1;
  while (no--) {
    solve();
  }
  return 0;
}