mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-10 03:18:53 +00:00
P4643 [国家集训队]阿狸和桃子的游戏
R40516157
This commit is contained in:
parent
8d3e6bb39a
commit
4df21c738a
23
problem/P4643/P4643.cpp
Normal file
23
problem/P4643/P4643.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user