Advertisement
Josif_tepe

Untitled

Feb 25th, 2024
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. #include <iostream>
  2. //#include <bits/stdc++.h>
  3. #include <fstream>
  4. #include <string>
  5. #include <set>
  6.  
  7. #define MOD 1000000007
  8. #define ll long long
  9. using namespace std;
  10.  
  11. int main() {
  12.     int t;
  13.     cin >>t;
  14.     while(t--){
  15.         int n,m;
  16.         cin >> n;
  17.         set<double> ms1;
  18.         set<double> ms2;
  19.         multiset<double> tempms1;
  20.         multiset<double> tempms2;
  21.         double avrg1, avrg2;
  22.         int res = 0;
  23.         double sum1 = 0,sum2 = 0;
  24.         for(int i =0;i<n;i++){
  25.             double a;
  26.             cin >> a;
  27.             sum1+=a;
  28.             ms1.insert(a);
  29.             tempms1.insert(a);
  30.         }
  31.         cin  >> m;
  32.         for(int  i =0;i<m;i++){
  33.             double a;
  34.             cin >> a;
  35.             ms2.insert(a);
  36.             sum2+=a;
  37.             tempms2.insert(a);
  38.         }
  39.         avrg1 = sum1 / n;
  40.         avrg2 = sum2 / m;
  41.         for(auto x : ms1){
  42.             double tempavrg1, tempavrg2;
  43.             tempavrg1 = (sum1-x)/(n-1);
  44.             tempavrg2 = (sum2+x)/(m+1);
  45.    
  46.             if(tempavrg1>avrg1 and tempavrg2>avrg2){
  47.                 res+= tempms1.count(x);
  48.             }
  49.         }
  50.         for(auto x:ms2){
  51.             double tempavrg1, tempavrg2;
  52.             tempavrg1 = (sum1+x)/(n+1);
  53.             tempavrg2 = (sum2-x)/(m-1);
  54.             if(tempavrg1>avrg1 and tempavrg2>avrg2){
  55.                 res+= tempms2.count(x);
  56.             }
  57.         }
  58.     cout << res<<endl;
  59.        
  60.     }
  61.    
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement