Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- using namespace std;
- int main() {
- int N, S, X, n, minNum = 2147483647;
- cin >> N >> S >> X;
- queue<int> numbers;
- for (int i = 0; i < N; i++) {
- cin >> n;
- numbers.push(n);
- }
- for (int i = 0; i < S; i++) {
- numbers.pop();
- if (numbers.empty()) {
- cout << '0' << endl;
- return 0;
- }
- }
- while (!numbers.empty()) {
- if (numbers.front() == X) {
- cout << "true" << endl;
- return 0;
- }
- else if (numbers.front() < minNum) {
- minNum = numbers.front();
- }
- numbers.pop();
- }
- cout << minNum << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement