Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct xe
- {
- long long a,b,vt;
- bool operator()(const xe x, const xe y) const {
- return x.a/x.b>y.a/y.b;}
- } ;
- long long n;
- int main()
- { vector <xe> xe;
- freopen("Car.inp","r",stdin);
- cin>>n;
- for(int i=1;i<=n;i++)
- {cin>>xe[i].a;xe[i].vt=i;}
- for(int i=1;i<=n;i++)
- {cin>>xe[i].b;}
- sort(xe+1,xe+n+1,operator());
- long long tong=0,dem=0;
- for(int i=1;i<=n;i++)
- { dem+=xe[i].b;
- tong+=xe[i].a*(dem);
- }
- cout<<tong<<endl;
- for(int i=1;i<n;i++)
- cout<<xe[i].vt<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement