Language: C++

#include<iostream>
#include<queue>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;
#define N 100000
#define M 300000
#define HT 1000000000
#define INF 2e18
#define int long long
#define MP(i, j) make_pair((i), (j))
typedef pair<int, int> P;
int n, m, x, ans = INF, tree[N + 1];
vector<P> g[N + 1];
int flag[N + 1] = {};
priority_queue<S> pq;

struct S {
	int to, fr, ti, nh;
	S(int i_fr, int i_to, int i_ti, int i_nh) : to(i_to), fr(i_fr), ti(i_ti), nh(i_nh) {}
	bool operator < (const S & s)const {
	  if(ti != s.ti)
		return ti > s.ti;
	}
};
void dijkstra(int sta) {
	for (int i = 0; i < g[1].size(); i++) {
		if (tree[1] >= g[1][i].second) {
			if (sta >= g[1][i].second) {
				if (sta > g[1][i].second + tree[g[1][i].first]) {
					pq.push({ 1, g[1][i].first, sta - tree[g[1][i].first],  tree[g[1][i].first] });
				}
				else {
					pq.push({ 1, g[1][i].first, g[1][i].second, sta - g[1][i].second });
				}
			}
			else {
				if (abs(sta - g[1][i].second) <= tree[1])
					pq.push({ 1, g[1][i].first, abs(sta - g[1][i].second) + g[1][i].second, 0 });
			}
		}
	}
	while (!pq.empty()) {
		S s = pq.top();
		pq.pop();
		if (flag[s.to] && flag[s.to] < s.ti) continue;
		flag[s.to] = s.ti;
		if (s.to == n) {
			ans = min(ans, tree[n] - s.nh + flag[s.to]);
			break;
		}
		for (int i = 0; i < g[s.to].size(); i++) {
			if (tree[s.to] >= g[s.to][i].second) {
				if (s.nh >= g[s.to][i].second) {
					if (s.nh > g[s.to][i].second + tree[g[s.to][i].first]) {
						pq.push({ s.to, g[s.to][i].first, s.nh - tree[g[s.to][i].first] + s.ti,  tree[g[s.to][i].first] });
					}
					else {
						pq.push({ s.to, g[s.to][i].first, g[s.to][i].second + s.ti, s.nh - g[s.to][i].second });
					}
				}
				else {
					if (g[s.to][i].second - s.nh <= tree[s.to])
						pq.push({ s.to, g[s.to][i].first, g[s.to][i].second - s.nh+ g[s.to][i].second + s.ti, 0 });
				}
			}
		}
	}
}
signed main() {
  scanf("%lld%lld%lld", &n, &m, &x);
	for (int i = 1; i <= n; i++)
		scanf("%lld", tree + i);
	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%lld%lld%lld", &a, &b, &c);
		g[a].push_back(MP(b, c));
		g[b].push_back(MP(a, c));
	}
		dijkstra(x);
	if (ans != INF)
		cout << ans << endl;
	else
		cout << -1 << endl;
}

Compiler output:
a.cc:18:16: error: 'S' was not declared in this scope
   18 | priority_queue<S> pq;
      |                ^
a.cc:18:17: error: template argument 1 is invalid
   18 | priority_queue<S> pq;
      |                 ^
a.cc:18:17: error: template argument 2 is invalid
a.cc:18:17: error: template argument 3 is invalid
a.cc: In function 'void dijkstra(long long int)':
a.cc:33:44: error: request for member 'push' in 'pq', which is of non-class type 'int'
   33 |                                         pq.push({ 1, g[1][i].first, sta - tree[g[1][i].first],  tree[g[1][i].first] });
      |                                            ^~~~
a.cc:36:44: error: request for member 'push' in 'pq', which is of non-class type 'int'
   36 |                                         pq.push({ 1, g[1][i].first, g[1][i].second, sta - g[1][i].second });
      |                                            ^~~~
a.cc:41:44: error: request for member 'push' in 'pq', which is of non-class type 'int'
   41 |                                         pq.push({ 1, g[1][i].first, abs(sta - g[1][i].second) + g[1][i].second, 0 });
      |                                            ^~~~
a.cc:45:20: error: request for member 'empty' in 'pq', which is of non-class type 'int'
   45 |         while (!pq.empty()) {
      |                    ^~~~~
a.cc:46:26: error: request for member 'top' in 'pq', which is of non-class type 'int'
   46 |                 S s = pq.top();
      |                          ^~~
a.cc:47:20: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   47 |                 pq.pop();
      |                    ^~~
a.cc:58:52: error: request for member 'push' in 'pq', which is of non-class type 'int'
   58 |                                                 pq.push({ s.to, g[s.to][i].first, s.nh - tree[g[s.to][i].first] + s.ti,  tree[g[s.to][i].first] });
      |                                                    ^~~~
a.cc:61:52: error: request for member 'push' in 'pq', which is of non-class type 'int'
   61 |                                                 pq.push({ s.to, g[s.to][i].first, g[s.to][i].second + s.ti, s.nh - g[s.to][i].second });
      |                                                    ^~~~
a.cc:66:52: error: request for member 'push' in 'pq', which is of non-class type 'int'
   66 |                                                 pq.push({ s.to, g[s.to][i].first, g[s.to][i].second - s.nh+ g[s.to][i].second + s.ti, 0 });
      |                                                    ^~~~