0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 00:48:47 +00:00

P4643 [国家集训队]阿狸和桃子的游戏

R40516157
This commit is contained in:
Baoshuo Ren 2020-10-25 19:54:10 +08:00 committed by Baoshuo Ren
parent 8d3e6bb39a
commit 4df21c738a
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

23
problem/P4643/P4643.cpp Normal file
View File

@ -0,0 +1,23 @@
#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;
}