SHARE
TWEET

Untitled

a guest Jun 20th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <math.h>
  4. #include <string>
  5. #include <deque>
  6. #include <utility>
  7. #include <sstream>
  8. #include <set>
  9. #include <algorithm>
  10. #include <numeric>
  11. #include <list>
  12. #define FIO ios::sync_with_stdio(0);
  13. # define NEW(type, count) ((type *)calloc(count, sizeof(type)))
  14. using namespace std;
  15. struct sett{int n,m,x,y;};
  16. int main(){
  17.   //freopen("mosalah.in" , stdin, "r");
  18.   int n;
  19.   cin>>n;
  20.   vector <sett> z(n);
  21.   for (int i=0;i<n;i++){
  22.     cin>>z[i].n>>z[i].m>>z[i].x>>z[i].y;
  23.   }
  24.   for (int i=0;i<n;i++){
  25.     int ans = ((z[i].x+z[i].y)*z[i].n)-z[i].m,curravg,avg;
  26.     if (z[i].m == 0){
  27.      curravg=0;
  28.     }else{
  29.      curravg = z[i].x/z[i].m;
  30.     }
  31.     if (z[i].n == 0){
  32.       avg=0;
  33.     }else{
  34.      avg = (z[i].x+z[i].y)/z[i].n;
  35.     }
  36.     if (z[i].y == 0){
  37.       cout<< -1<<endl;
  38.     }else if (curravg>avg||curravg==avg||ans<=0){
  39.       cout << 0<<endl;
  40.     }
  41.     else{
  42.       cout<<ans<<endl;
  43.     }
  44.   }
  45.  
  46. }
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