Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- #include <string>
- #include <iostream>
- #include <cstdlib>
- #include <vector>
- using namespace std;
- int main()
- {
- int lady, luchu;
- while(cin >> lady)
- {
- int lady_array[lady];
- int i, j, k;
- for(i = 0; i < lady; i++)
- cin >> lady_array[i];
- cin >> luchu;
- int luchu_array[luchu];
- for(i = 0; i < luchu; i++)
- cin >> luchu_array[i];
- for(i = 0; i < luchu; i++)
- {
- int flag1 = 0, flag2 = 0, a, b;
- for(j = 0; j < lady; j++)
- {
- if(lady_array[j] > luchu_array[i])
- {
- flag1 = 1;
- b = lady_array[j];
- break;
- }
- }
- for(k = j; k >= 0; k--)
- {
- if(lady_array[k] < luchu_array[i])
- {
- flag2 = 1;
- a = lady_array[k];
- break;
- }
- }
- if(flag1 == 0) b = -1;
- if(flag2 == 0) a = -1;
- if(a == -1)
- cout << "X " << b << endl;
- else if(b == -1)
- cout << a << " X" << endl;
- else
- cout << a << ' ' << b << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement