Saleh127

hackerearcth fight1

Sep 28th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. ll a[200005],c[200005];
  5. vector<ll>z;
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11.  
  12. ll n,k,f,i,e;
  13. scanf("%lld %lld",&n,&k);
  14. vector< pair <ll,ll> >x;
  15. for(i=0; i<n; i++)
  16. {
  17. scanf("%lld",&a[i]);
  18. }
  19. for(i=0; i<n; i++)
  20. {
  21. scanf("%lld",&c[i]);
  22. }
  23. for(i=0; i<n; i++)
  24. {
  25. x.push_back({c[i],a[i]});
  26. }
  27. sort(x.begin(), x.end());
  28. f=0;
  29. for(i=n-1; i>=0; i--)
  30. {
  31. f+=x[i].second;
  32. z.push_back(f);
  33. }
  34. while(k--)
  35. {
  36. scanf("%lld",&e);
  37. printf("%lld\n",z[e-1]);
  38. }
  39. return 0;
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment