fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. // your code goes here
  5. ios::sync_with_stdio(0);
  6. int n;
  7. cin>>n;
  8. int score[n],pos[n];
  9. for (int i = 0; i < n; i++) {
  10. cin>>score[i]>>pos[i];
  11. }
  12. int ans=0;
  13. for(int i=0;i<n;i++){
  14. for(int j=0;j<n;j++){
  15. ans=ans+abs(pos[i]-pos[j])*max(score[i],score[j]);
  16. }
  17. }
  18. cout<<ans;
  19. return 0;
  20. }
Time limit exceeded #stdin #stdout 5s 1054208KB
stdin
Standard input is empty
stdout
Standard output is empty