fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main() {
  7. int n, m, v[1005], x, y;
  8. long long int sum=0;
  9. scanf("%d%d", &n, &m);
  10. for(int i=0; i<n; i++) scanf("%d", &v[i]);
  11. for(int i=0; i<m; i++) {
  12. scanf("%d%d", &x, &y);
  13. sum+=min(v[x-1], v[y-1]);
  14. }
  15. printf("%lld", sum);
  16. return 0;
  17. }
Success #stdin #stdout 0s 3344KB
stdin
7 10
40 10 20 10 20 80 40
1 5
4 7
4 5
5 2
5 7
6 4
1 6
1 3
4 3
1 4
stdout
160