SHARE
TWEET

codeforce - The Doors

jakaria_hossain Mar 31st, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fastread()(ios_base:: sync_with_stdio(false),cin.tie(NULL));
  5. int main()
  6. {
  7.     fastread();
  8.     int n;
  9.     cin>>n;
  10.     int ara[n+1],z=0,o=0,zc=0,oc=0,k;
  11.     for(int i=0; i<n; i++)
  12.     {
  13.         cin>>ara[i];
  14.         if(ara[i]==0)
  15.             z++;
  16.         else
  17.             o++;
  18.     }
  19.     for(int i=0; i<n; i++)
  20.     {
  21.         if(ara[i]==0)
  22.         {
  23.             zc++;
  24.             if(zc==z)
  25.             {
  26.                 k=i;
  27.                 break;
  28.             }
  29.         }
  30.         else
  31.         {
  32.             oc++;
  33.             if(oc==o)
  34.             {
  35.                 k=i;
  36.                 break;
  37.             }
  38.         }
  39.     }
  40.     printf("%d\n",k+1);
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top