691A - Fashion in Berland - CodeForces Solution


implementation *1000

Please click on ads to support us..

Python Code:

n=int(input())
a=input()
print('NYOE S'[(n<2 and a.count('1')) or (n>1 and a.count('0')==1)::2])

C++ Code:

#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define cn cout<<"NO"<<endl
#define cy cout<<"YES"<<endl
#define pb push_back

int main() {
    ll n;
    cin>>n;
    ll ct0=0;
    for(int i=0;i<n;i++) {
      ll x;
      cin>>x;
      if(x==0){
        ct0++;
      }
    }
    if(n==1&&ct0==0){
      cy;
    }
    else if(n>1&&ct0==1){
      cy;
    }
    else {
      cn;
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1637A - Sorting Parts
509A - Maximum in Table
1647C - Madoka and Childish Pranks
689B - Mike and Shortcuts
379B - New Year Present
1498A - GCD Sum
1277C - As Simple as One and Two
1301A - Three Strings
460A - Vasya and Socks
1624C - Division by Two and Permutation
1288A - Deadline
1617A - Forbidden Subsequence
914A - Perfect Squares
873D - Merge Sort
1251A - Broken Keyboard
463B - Caisa and Pylons
584A - Olesya and Rodion
799A - Carrot Cakes
1569B - Chess Tournament
1047B - Cover Points
1381B - Unmerge
1256A - Payment Without Change
908B - New Year and Buggy Bot
979A - Pizza Pizza Pizza
731A - Night at the Museum
742A - Arpa’s hard exam and Mehrdad’s naive cheat
1492A - Three swimmers
1360E - Polygon
1517D - Explorer Space
1230B - Ania and Minimizing