Advertisement
Rofyda_Elghadban1

Untitled

Sep 15th, 2023
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1.  #include <bits/stdc++.h>
  2.  
  3.  #define ll long long
  4.  #define ull unsigned long long
  5.  #define pi 3.141592654
  6.  #define NUM 1e18
  7.  #define Mod  1'000'000'007
  8.  #define fixed(n) fixed<<setprecision(n)
  9.  #define cin(v) for(auto &i:v) cin >> i ;
  10.  #define cout(v) for(auto &i:v) cout << i  <<" ";
  11.  #define vowel(x) (x=='e'||x=='a'||x=='i'||x=='o'||x=='u')
  12.  #define small(x) (x>=97&&x<=122)
  13.  #define capital(x) (x>=65&&x<=90)
  14.  #define Tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
  15.  #define Toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
  16.  #define all(v) ((v).begin()), ((v).end())
  17.  #define allr(v) ((v).rbegin()), ((v).rend())
  18.  #define updmax(a,b) a=max(a,b)
  19.  #define updmin(a,b) a=min(a,b)
  20.  #define ceil(a,b) ((a/b)+(a%b?1:0))
  21.  /* asc -> 1 2 3 ,des -> 3 2 1 */
  22.  
  23.  /***********************************************************************************/
  24.  
  25.  using namespace std;
  26.  
  27.  void Rofyda_Elghadban(){
  28.   #ifndef ONLINE_JUDGE  
  29.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  30.    #endif
  31.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  32.  }
  33.  
  34.  
  35.  void solve(){
  36.   int n;
  37.   cin>>n;
  38.   vector<int>v(n);
  39.   cin(v);
  40.   int freq[10001]{};
  41.   if(n==1){
  42.     if(v[0]==0){
  43.       cout<<"NO"<<"\n";
  44.     }else{
  45.       cout<<"YES"<<"\n";
  46.     }
  47.   }else{
  48.     for(int i=0;i<n;i++){
  49.       freq[v[i]]++;
  50.     }
  51.     if(freq[0]!=1){
  52.       cout<<"NO"<<"\n";
  53.     }else{
  54.       cout<<"YES"<<"\n";
  55.     }
  56.   }
  57.  }
  58.  
  59.  
  60.  int main(){
  61.  Rofyda_Elghadban();
  62.  //freopen("input.txt","r",stdin);
  63.  //freopen("output.txt","r",stdout);
  64.  solve();
  65.  
  66.  
  67.  
  68.  
  69.  return 0;
  70. }
  71.  
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement