Saleh127

CF 546B.

Jul 28th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. ll a[20000],c,d,e=0,f,i,j,k,l;
  10. cin>>c;
  11. for(i=0;i<c;i++)
  12. {
  13. cin>>a[i];
  14. }
  15. sort(a,a+c);
  16. for(i=1;i<c;i++)
  17. {
  18. if(a[i]-a[i-1]>=1)
  19. {
  20. continue;
  21. }
  22. else
  23. {
  24. d=llabs(a[i]-a[i-1])+1;
  25. a[i]=a[i]+d;
  26. e+=d;
  27. }
  28. }
  29. cout<<e<<endl;
  30. return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment