Advertisement
Saleh127

Cf 1392b

Aug 16th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);
  7. cout.tie(0);
  8.  
  9. int t;
  10. cin>>t;
  11. while(t--)
  12. {
  13. long long a[200005],c,d,e=-2000000000,f,i,j,k,l;
  14. cin>>c>>k;
  15. for(i=0; i<c; i++)
  16. {
  17. cin>>a[i];
  18. e=max(e,a[i]);
  19. }
  20. if(k%2==1)
  21. {
  22. for(i=0; i<c; i++)
  23. {
  24. cout<<e-a[i]<<" ";
  25. }
  26. cout<<endl;
  27. }
  28. else
  29. {
  30. f=-2000000000;
  31. for(i=0; i<c; i++)
  32. {
  33. a[i]=e-a[i];
  34. f=max(f,a[i]);
  35. }
  36. for(i=0; i<c; i++)
  37. {
  38. cout<<f-a[i]<<" ";
  39. }
  40. cout<<endl;
  41. }
  42. }
  43. return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement