Run ID:105645

提交时间:2025-01-14 10:57:22

#include <iostream> using namespace std; int main() { int n, m, first = -1, last = -1; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } cin >> m; for (int i = 0; i < n; i++) { if (arr[i] == m) { if (first == -1) { first = i + 1; } last = i + 1; } } if (first == -1) { cout <<-1 << endl; } else { cout << first << " " << last << endl; } return 0; }