-
-
Save veigavitor/4ea66a9ec46a2cabac7c2094f14bc494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int32_t main() { | |
ios::sync_with_stdio(false); | |
cin.tie(nullptr); | |
// lemos a entrada | |
int n, d; | |
cin >> n >> d; | |
vector<int> t(n); | |
for(int i = 0; i < n; i++) { | |
cin >> t[i]; | |
} | |
// passamos pelos tempos, começando no segundo, checando | |
// se o tempo atual menos o último tempo é menor que 'd' | |
// se for, retornamos o tempo atual e finalizamos o programa | |
for(int i = 1; i < n; i++) { | |
if(t[i] - t[i-1] <= d) { | |
cout << t[i] << endl; | |
return 0; | |
} | |
} | |
// se não houver duplo clique, retornamos -1 | |
cout << -1 << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment