Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int block[10005],L,K,a[10005],b,c,Z[10005];
- int main()
- {
- cin >> L >> K;
- for ( int i = 0; i < K; i++ )
- {
- cin >> block[i];
- Z[block[i]] = block[i];
- }
- for ( int i = 0; i < L; i++ )
- {
- a[block[i]] = 1;
- }
- if ( L%2 == 1 && a[L/2] == 1 )
- {
- cout << block[a[block[L/2]]];
- return 0;
- }
- else
- {
- for ( int i = 0; i < L/2; i++ )
- {
- if ( a[i] == 1 ) b++;
- }
- for ( int i = L/2+1; i <= L; i++ )
- {
- if ( a[i] == 1 ) c++;
- }
- }
- int j = 0;
- if ( b != 1 || c != 1 )
- {
- while ( b != 1 )
- {
- if ( a[j] == 1 )
- {
- a[j] = 0;
- b--;
- }
- j++;
- }
- j = L;
- while ( c != 1 )
- {
- if ( a[j] == 1 )
- {
- a[j] = 0;
- c--;
- }
- j--;
- }
- }
- for ( int i = 0; i < L; i++ )
- {
- if ( a[i] == 1 )
- {
- cout << Z[i] << " ";
- }
- }
- //for ( int i = 0; i < L; i++ )
- {
- //cout << a[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement