Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. struct xe
  5. {
  6. long long a,b,vt;
  7. bool operator()(const xe x, const xe y) const {
  8.  
  9. return x.a/x.b>y.a/y.b;}
  10. } ;
  11. long long n;
  12. int main()
  13. { vector <xe> xe;
  14. freopen("Car.inp","r",stdin);
  15. cin>>n;
  16.  
  17. for(int i=1;i<=n;i++)
  18. {cin>>xe[i].a;xe[i].vt=i;}
  19. for(int i=1;i<=n;i++)
  20. {cin>>xe[i].b;}
  21. sort(xe+1,xe+n+1,operator());
  22. long long tong=0,dem=0;
  23. for(int i=1;i<=n;i++)
  24. { dem+=xe[i].b;
  25. tong+=xe[i].a*(dem);
  26. }
  27. cout<<tong<<endl;
  28. for(int i=1;i<n;i++)
  29. cout<<xe[i].vt<<" ";
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement