Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define REP(i,n) for(int i=0; i<(n); i++)
- #define ALL(n) begin(n),end(n)
- struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
- int main()
- {
- int n, m;
- cin >> n >> m;
- vector<int> vc( m );
- REP( i, m )
- {
- cin >> vc[ i ];
- }
- sort( ALL( vc ) );
- vector<int> res;
- for( int i = 0; n - 1 + i < m; i++ )
- {
- res.emplace_back( vc[ n - 1 + i ] - vc[ i ] );
- }
- cout << *min_element( ALL( res ) ) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement