mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 20:56:37 +00:00
24 lines
462 B
C++
24 lines
462 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
int n, m, x, y, z, k, ans = 0, a[10001];
|
|
cin >> n >> m;
|
|
for (int i = 1; i <= n; i++) {
|
|
cin >> k;
|
|
a[i] = k << 1;
|
|
}
|
|
for (int i = 0; i < m; i++) {
|
|
cin >> x >> y >> z;
|
|
a[x] += z;
|
|
a[y] += z;
|
|
}
|
|
sort(a + 1, a + n + 1);
|
|
for (int i = n; i >= 1; i -= 2) {
|
|
ans += a[i] - a[i - 1];
|
|
}
|
|
cout << ans / 2 << endl;
|
|
return 0;
|
|
}
|