You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
489 B
C++
24 lines
489 B
C++
#include <cstdio>
|
|
#include <algorithm>
|
|
int a[10010];
|
|
int main()
|
|
{
|
|
int n, m, ans = 0;
|
|
scanf("%d%d", &n, &m);
|
|
for (int i = 1, x; i <= n; i++)
|
|
{
|
|
scanf("%d", &x);
|
|
ans -= x;
|
|
a[i] = x << 1;
|
|
}
|
|
for (int i = 1, x, y, z; i <= m; i++)
|
|
{
|
|
scanf("%d%d%d", &x, &y, &z);
|
|
ans -= z, a[x] += z, a[y] += z;
|
|
}
|
|
std::sort(a + 1, a + n + 1);
|
|
for (int i = 2; i <= n; i += 2)
|
|
ans += a[i];
|
|
printf("%d", ans);
|
|
return 0;
|
|
} |