Codeforces Fashion in Berland
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
int n;
while(cin >> n)
{
int cnt=0 , i=0;
while(i<n)
{
int x;
cin >> x;
if(x) cnt++;
i++;
}
if(n==1)
{
if(cnt>0) cout << "YES\n";
else cout << "NO\n";
}
else
{
if(cnt == (n-1)) cout << "YES\n";
else cout << "NO\n";
}
}
return 0;
}
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
int n;
while(cin >> n)
{
int cnt=0 , i=0;
while(i<n)
{
int x;
cin >> x;
if(x) cnt++;
i++;
}
if(n==1)
{
if(cnt>0) cout << "YES\n";
else cout << "NO\n";
}
else
{
if(cnt == (n-1)) cout << "YES\n";
else cout << "NO\n";
}
}
return 0;
}
Comments
Post a Comment