45 lines
631 B
C++
45 lines
631 B
C++
#include <iostream>
|
|
#include <fstream>
|
|
#include <algorithm>
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
ifstream input_stream;
|
|
ofstream output_stream;
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
input_stream.open("input.txt");
|
|
output_stream.open("output.txt");
|
|
|
|
uint32_t N, K, R, P;
|
|
input_stream >> N;
|
|
input_stream >> K;
|
|
input_stream >> R;
|
|
|
|
uint32_t rounds[R] = {};
|
|
|
|
for (uint32_t i = 0; i < R; i++) {
|
|
input_stream >> rounds[i];
|
|
}
|
|
|
|
input_stream >> P;
|
|
|
|
for (int i = R - 1; i >=0; i--) {
|
|
if (P == N) {
|
|
P = rounds[i];
|
|
} else if (P >= rounds[i]) {
|
|
P++;
|
|
}
|
|
}
|
|
|
|
cout << P << endl;
|
|
|
|
input_stream.close();
|
|
output_stream.close();
|
|
return 0;
|
|
}
|