fork download
  1. #include <iostream>
  2. #include <utility>
  3. #include <bits/stdc++.h>
  4.  
  5. #define ll long long
  6. #define endll '\n'
  7. #define FOR for(int i = 0; i < n; i++)
  8.  
  9. using namespace std;
  10.  
  11. void fastIO()
  12. {
  13. ios_base::sync_with_stdio(false);
  14. cin.tie(NULL);
  15. cout.tie(NULL);
  16. }
  17.  
  18. void solve(){
  19. int n; ll k;
  20. cin >> n >> k;
  21.  
  22. queue<int>que;
  23. FOR{
  24. int e;
  25. cin >> e;
  26. que.push(e);
  27. }
  28. int player1 = que.front();
  29. que.pop();
  30. ll cnt = 0;
  31. while(k != cnt ) {
  32. if (player1 > que.front()) {
  33. cnt++;
  34. }
  35. else{
  36. player1 = que.front();
  37. cnt = 0;
  38. }
  39. if(!que.empty()) que.pop();
  40. else break;
  41. }
  42. cout << player1 << endll;
  43.  
  44. }
  45.  
  46.  
  47. int main() {
  48. fastIO();
  49.  
  50. solve();
  51. return 0;
  52. }
  53.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
0