SHARE
TWEET

Untitled

a guest Dec 10th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top