SHARE
TWEET

codeforce - xenia and divisors

jakaria_hossain Jul 10th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n;
  6.     cin>>n;
  7.     int ara[n+1],o=0,t=0,tr=0,f=0,s=0;
  8.     bool fl= false;
  9.     for(int i=0;i<n;i++)
  10.     {
  11.         cin>>ara[i];
  12.         if(ara[i]==5 || ara[i]==7)fl=true;
  13.         if(ara[i]==1)o++;
  14.         if(ara[i]==2)t++;
  15.         if(ara[i]==3)tr++;
  16.         if(ara[i]==4)f++;
  17.         if(ara[i]==6)s++;
  18.     }
  19.     //cout<<o<<" "<<t<<" "<<tr<<" "<<f<< " "<<s<<endl;
  20.     if(!fl && tr<=s && t<=f+s && o==t+tr)
  21.     {
  22.         for(int i=0;i<tr;i++)
  23.             cout<<"1 3 6"<<endl;
  24.         for(int i=0;i<f;i++)
  25.             cout<<"1 2 4"<<endl;
  26.         for(int i=tr;i<s;i++)
  27.             cout<<"1 2 6"<<endl;
  28.     }
  29.     else cout<<"-1"<<endl;
  30.  
  31. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top