Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define REP(i,n) for(int i=0; i<(n); i++)
  4. #define ALL(n) begin(n),end(n)
  5. struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
  6. int main()
  7. {
  8. int n, m;
  9. cin >> n >> m;
  10. vector<int> vc( m );
  11. REP( i, m )
  12. {
  13. cin >> vc[ i ];
  14. }
  15. sort( ALL( vc ) );
  16. vector<int> res;
  17. for( int i = 0; n - 1 + i < m; i++ )
  18. {
  19. res.emplace_back( vc[ n - 1 + i ] - vc[ i ] );
  20. }
  21. cout << *min_element( ALL( res ) ) << endl;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement