fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. struct child{
  4. int age,cost;
  5. };
  6. bool compare(child c1,child c2){
  7. return c1.age>c2.age;
  8. }
  9. bool compare2(child c1,child c2){
  10. return c1.cost>c2.cost;
  11. }
  12. int main(){
  13. int t;
  14. cin>>t;
  15. while(t--){
  16. int arr[6];child arr2[3],arr3[3];
  17. for(int i=0;i<6;i++){
  18. cin>>arr[i];
  19. }
  20. int j=0;
  21. for(int i=0;i<3;i++){
  22. arr2[j].age=arr[i];
  23. arr2[j].cost=arr[i+3];
  24. j++;
  25. }
  26. for(int i=0;i<3;i++){
  27. arr3[i].age=arr2[i].age;
  28. arr3[i].cost=arr2[i].cost;
  29. }
  30. sort(arr2,arr2+3,compare);
  31. sort(arr3,arr3+3,compare2);
  32. cout<<"-----------------"<<endl;
  33. for(int i=0;i<3;i++){
  34. cout<<arr2[i].age<< " " <<arr2[i].cost<<endl;
  35. }
  36. cout<<"*************"<<endl;
  37. for(int i=0;i<3;i++){
  38. cout<<arr3[i].age<< " " <<arr3[i].cost<<endl;
  39. }
  40. cout<<"*************"<<endl;
  41.  
  42. int count=0;
  43. for(int i=0;i<3;i++){
  44. if(arr2[i].age==arr3[i].age){
  45.  
  46. if(arr2[i].cost==arr3[i].cost)
  47. count++;
  48.  
  49. }
  50. }
  51. if(count==3)cout<<"FAIR"<<endl;
  52. else cout<<"NOT FAIR"<<endl;
  53. }
  54.  
  55.  
  56.  
  57.  
  58.  
  59. return 0;
  60. }
Success #stdin #stdout 0s 4356KB
stdin
2
5 5 5 20 20 10
5 5 5 20 10 20
stdout
-----------------
5 20
5 20
5 10
*************
5 20
5 20
5 10
*************
FAIR
-----------------
5 20
5 10
5 20
*************
5 20
5 20
5 10
*************
NOT FAIR