Created
April 25, 2026 09:11
-
-
Save thinkphp/ead6365952a05fb7c6d2ff6d341865e6 to your computer and use it in GitHub Desktop.
False Alarm CodeForces.com codeforces-false-alarm.cpp
This file contains hidden or 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
| void solve() { | |
| int n, x;//dimnesiune si butonul apasat: x secunde | |
| cin>>n>>x; | |
| int l = 1e5, r = -1; | |
| for(int i = 0; i < n; ++i) { | |
| int door; | |
| cin>>door; | |
| if(door == 1) {//daca usa este inchisa 1 | |
| l = min(l, i); //aflu indicele pe care se afla prima usa inchisa | |
| r = max(r, i);//aflu indicele pe care se afla ultima usa inchisa | |
| } | |
| cout<< (x >= r - l + 1) ? "YES" : "NO"; //afli daca intervalul este mai mic sau egal decat numarul de secunde x | |
| } | |
| } | |
| int main() { | |
| int T; | |
| cin>>T; | |
| while(T--) solve(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment