karlangadas

Next Round cf

Dec 27th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main() {
  7.     int n,k,r,ans=0;
  8.     cin>>n>>k;
  9.     for (int i=0;i<k;i++){
  10.         cin>>r;
  11.         if (r<=0){
  12.             cout<<ans<<endl;
  13.             return 0;
  14.         }
  15.         ans++;
  16.     }
  17.     int last=r;
  18.     while((ans<n)&& (cin>>r)&&(r==last)){
  19.         ans++;
  20.     }
  21.     cout<<ans<<endl;
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment