fork download
  1. /*
  2. Developed by Ganesh Sawhney
  3. */
  4.  
  5. #include <bits/stdc++.h>
  6.  
  7. using namespace std;
  8. typedef long long ll;
  9.  
  10. int main()
  11. {
  12. //ifstream in("test3.txt");
  13. //ofstream out("output.txt");
  14.  
  15. int n,m;
  16. cin>>n>>m;
  17. int w[n];
  18. ll ans=0;
  19. for(int i=0;i<n;i++)
  20. {
  21. cin>>w[i];
  22. }
  23. for(int i=0;i<m;i++)
  24. {
  25. int a,b;
  26. cin>>a>>b;
  27. a--,b--;
  28. ans+=min(w[a],w[b]);
  29. }
  30. cout<<ans<<endl;
  31. return 0;
  32. }
  33.  
Runtime error #stdin #stdout 0s 2728KB
stdin
Standard input is empty
stdout
Standard output is empty