https://ac.nowcoder.com/acm/contest/24872/H
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
typedef long long LL;
#define debug(x) cout << "debug : " << x << endl;
#define int long long
int pre[N], fa[N][22];
int n, m, q;
int sz[N];
struct EDGE {
int u, v, w;
bool operator < (const EDGE& a) const {
return w < a.w;
}
}edge[N];
vector<int>g[N];
int rt, root[N];
int find(int x) {
if (x != pre[x]) {
return pre[x] = find(pre[x]);
}
return pre[x];
}
void Kruskal() {
rt = n;
sort(edge + 1, edge + 1 + m);
for (int i = 1; i <= m; ++i) {
int fx = find(edge[i].u), fy = find(edge[i].v), w = edge[i].w;
if (fx != fy) {
++rt;
pre[fx] = pre[fy] = pre[rt] = rt;
root[rt] = w;
g[rt].push_back(fx);
g[rt].push_back(fy);
}
}
}
void dfs(int u, int fat) {
fa[u][0] = fat;
for (int i = 1; i <= 20; ++i) {
fa[u][i] = fa[fa[u][i - 1]][i - 1];
}
for (int i = 0; i < g[u].size(); ++i) {
int v = g[u][i];
dfs(v, u);
sz[u] += sz[v];
}
}
void solve() {
cin >> n >> m >> q;
for (int i = 1; i <= n + m; ++i) {
pre[i] = i;
}
for (int i = 1; i <= n; ++i) {
cin >> sz[i];
}
for (int i = 1; i <= m; ++i) {
int u, v, w; cin >> u >> v >> w;
edge[i] = {u, v, w};
}
Kruskal();
dfs(rt, 0);
while (q--) {
int u, s; cin >> u >> s;
int now = s + sz[u];
while (u != rt) {
int x = u;
for (int i = 20; i >= 0; --i) {
if (fa[u][i] && root[fa[u][i]] <= now) {
u = fa[u][i];
}
}
if (x == u) break;
now = sz[u] + s;
}
cout << now << "\n";
}
}
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
freopen("../in", "r", stdin);
// freopen("../out", "w", stdout);
#endif
int T = 1;
// cin >> T;
// scanf("%d", &T);
while (T--) {
solve();
}
}