Language: C++

#include <cstdio>
#include <vector>
using namespace std;

#define long long Int
typedef pair<Int, int> p;
typedef pair<int, int> pp;

int main(){
	const int MAX_N = 100000;
	int N, M, X, H[MAX_N + 1];
	int u, v, c;
	p d[MAX_N + 1];
	vector<pp> V[MAX_N + 1];
	bool updated;
	int to, cost, height;
	
	scanf("%d%d%d", &N, &M, &X);
	for(int i = 1; i <= N; i++){
		scanf("%d", H + i);
	}
	for(int i = 0; i < M; i++){
		scanf("%d%d%d", &u, &v, &c);
		V[u].push_back(pp(v, c));
		V[v].push_back(pp(u, c));
	}
	
	updated = true;
	for(int i = 1; i <= N; i++){
		d[i].first = -1;
		d[i].second = -1;
	}
	d[1].first = 0; d[1].second = X;
	while(updated){
		updated = false;
		for(int i = 1; i <= N; i++){
			if(V[i].empty() || d[i].first == -1 || d[i].second == -1) continue;
			for(int j = 0; j < V[i].size(); j++){
				to = V[i][j].first;
				if(H[i] < V[i][j].second) continue;
				
				if(d[i].second - V[i][j].second >= 0){
					if(d[i].second - V[i][j].second <= H[to]){
						cost = V[i][j].second;
						height = d[i].second - V[i][j].second;
					}
					else{
						cost = d[i].second - H[to];
						height = H[to];
					}
				}
				else{
					cost = V[i][j].second + (V[i][j].second - d[i].second);
					height = 0;
				}
				
				if(to == N){
					if(d[to].first == -1 || (d[i].first + cost) + (H[to] - height) < d[to].first + (H[to] - d[to].second)){
						d[to].first = d[i].first + cost;
						d[to].second = height;
						updated = true;
					}
				}
				else{
					if(d[to].first == -1 || d[i].first + cost < d[to].first){
						d[to].first = d[i].first + cost;
						d[to].second = height;
						updated = true;
					}
				}
			}
		}
	}
	
	printf("%lld\n", (d[N].first == -1)? -1 : (d[N].first + (H[N] - d[N].second)));
	
	return 0;
}

Compiler output:
a.cc:6:14: error: 'Int' was not declared in this scope; did you mean 'int'?
    6 | typedef pair<Int, int> p;
      |              ^~~
      |              int
a.cc:6:22: error: template argument 1 is invalid
    6 | typedef pair<Int, int> p;
      |                      ^
a.cc: In function 'int main()':
a.cc:30:22: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   30 |                 d[i].first = -1;
      |                      ^~~~~
a.cc:31:22: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   31 |                 d[i].second = -1;
      |                      ^~~~~~
a.cc:33:14: error: request for member 'first' in 'd[1]', which is of non-class type 'p' {aka 'int'}
   33 |         d[1].first = 0; d[1].second = X;
      |              ^~~~~
a.cc:33:30: error: request for member 'second' in 'd[1]', which is of non-class type 'p' {aka 'int'}
   33 |         d[1].first = 0; d[1].second = X;
      |                              ^~~~~~
a.cc:37:49: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   37 |                         if(V[i].empty() || d[i].first == -1 || d[i].second == -1) continue;
      |                                                 ^~~~~
a.cc:37:69: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   37 |                         if(V[i].empty() || d[i].first == -1 || d[i].second == -1) continue;
      |                                                                     ^~~~~~
a.cc:42:41: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   42 |                                 if(d[i].second - V[i][j].second >= 0){
      |                                         ^~~~~~
a.cc:43:49: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   43 |                                         if(d[i].second - V[i][j].second <= H[to]){
      |                                                 ^~~~~~
a.cc:45:63: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   45 |                                                 height = d[i].second - V[i][j].second;
      |                                                               ^~~~~~
a.cc:48:61: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   48 |                                                 cost = d[i].second - H[to];
      |                                                             ^~~~~~
a.cc:53:88: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   53 |                                         cost = V[i][j].second + (V[i][j].second - d[i].second);
      |                                                                                        ^~~~~~
a.cc:58:50: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'}
   58 |                                         if(d[to].first == -1 || (d[i].first + cost) + (H[to] - height) < d[to].first + (H[to] - d[to].second)){
      |                                                  ^~~~~
a.cc:58:71: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   58 |                                         if(d[to].first == -1 || (d[i].first + cost) + (H[to] - height) < d[to].first + (H[to] - d[to].second)){
      |                                                                       ^~~~~
a.cc:58:112: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'}
   58 |                                         if(d[to].first == -1 || (d[i].first + cost) + (H[to] - height) < d[to].first + (H[to] - d[to].second)){
      |                                                                                                                ^~~~~
a.cc:58:135: error: request for member 'second' in 'd[to]', which is of non-class type 'p' {aka 'int'}
   58 |                                         if(d[to].first == -1 || (d[i].first + cost) + (H[to] - height) < d[to].first + (H[to] - d[to].second)){
      |                                                                                                                                       ^~~~~~
a.cc:59:55: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'}
   59 |                                                 d[to].first = d[i].first + cost;
      |                                                       ^~~~~
a.cc:59:68: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   59 |                                                 d[to].first = d[i].first + cost;
      |                                                                    ^~~~~
a.cc:60:55: error: request for member 'second' in 'd[to]', which is of non-class type 'p' {aka 'int'}
   60 |                                                 d[to].second = height;
      |                                                       ^~~~~~
a.cc:65:50: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'}
   65 |                                         if(d[to].first == -1 || d[i].first + cost < d[to].first){
      |                                                  ^~~~~
a.cc:65:70: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   65 |                                         if(d[to].first == -1 || d[i].first + cost < d[to].first){
      |                                                                      ^~~~~
a.cc:65:91: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'}
   65 |                                         if(d[to].first == -1 || d[i].first + cost < d[to].first){
      |                                                                                           ^~~~~
a.cc:66:55: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'}
   66 |                                                 d[to].first = d[i].first + cost;
      |                                                       ^~~~~
a.cc:66:68: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'}
   66 |                                                 d[to].first = d[i].first + cost;
      |                                                                    ^~~~~
a.cc:67:55: error: request for member 'second' in 'd[to]', which is of non-class type 'p' {aka 'int'}
   67 |                                                 d[to].second = height;
      |                                                       ^~~~~~
a.cc:75:32: error: request for member 'first' in 'd[N]', which is of non-class type 'p' {aka 'int'}
   75 |         printf("%lld\n", (d[N].first == -1)? -1 : (d[N].first + (H[N] - d[N].second)));
      |                                ^~~~~
a.cc:75:57: error: request for member 'first' in 'd[N]', which is of non-class type 'p' {aka 'int'}
   75 |         printf("%lld\n", (d[N].first == -1)? -1 : (d[N].first + (H[N] - d[N].second)));
      |                                                         ^~~~~
a.cc:75:78: error: request for member 'second' in 'd[N]', which is of non-class type 'p' {aka 'int'}
   75 |         printf("%lld\n", (d[N].first == -1)? -1 : (d[N].first + (H[N] - d[N].second)));
      |                                                                              ^~~~~~