Snapper_001

Untitled

Jul 5th, 2022
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  3. #define pb                          push_back
  4. #define all(x)                      (x).begin(),(x).end()
  5. #define ll                          long long
  6. #define ld                          long double
  7. #define eps                         1e-9
  8. #define sz(a)                       (ll)(a).size()
  9. #define print(ans)                  cout<<(ans?"YES":"NO")<<endl;
  10. #define ppc                         __builtin_popcount
  11. #define ppcll                       __builtin_popcountll
  12. #define endl                        "\n"
  13. #define lb                          lower_bound
  14. #define ub                          upper_bound
  15. const ld PI = 3.141592653589793238462;
  16. const int MOD = 1e9 +7;
  17. const ll INF = 1e18;
  18. // if(abs(a-b)<eps) --> if(a==b)
  19. // fixed << setprecision(n) -->printing decimal till n
  20. // hypot(a ,b) --> sqrt(a^2 + b^2)
  21. using namespace std;
  22.  
  23. void solve(){
  24.     ll n,x,y,a;
  25.     cin>>n>>x>>y>>a;
  26.    
  27.     ll total_shampoo =0;
  28.     for(int i=0;i<a;i++){
  29.         ll per;
  30.         cin>>per;
  31.         total_shampoo += per*10;
  32.     }
  33.  
  34.     ll days_for_summer_break = n*14;
  35.     total_shampoo -= (days_for_summer_break/y)*x;
  36.  
  37.     if(total_shampoo<0){
  38.         cout<<-1<<endl;
  39.         return;
  40.     }
  41.  
  42.     ll remi = days_for_summer_break%y;
  43.     if(remi==0 && total_shampoo>=0 && total_shampoo<x){
  44.         cout<<0<<endl;
  45.     }
  46.     else{
  47.         if(total_shampoo<x){
  48.             cout<<-1<<endl;
  49.         }
  50.         else{
  51.             ll ans = (total_shampoo/x)*y - remi;
  52.             cout<<ans<<endl;
  53.         }
  54.     }
  55.  
  56. }
  57.  
  58. int main(){
  59.     IO;
  60.     ll t =1;
  61.     cin>>t;
  62.     while(t--){
  63.         solve();
  64.     }
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment