Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
- #define pb push_back
- #define all(x) (x).begin(),(x).end()
- #define ll long long
- #define ld long double
- #define eps 1e-9
- #define sz(a) (ll)(a).size()
- #define print(ans) cout<<(ans?"YES":"NO")<<endl;
- #define ppc __builtin_popcount
- #define ppcll __builtin_popcountll
- #define endl "\n"
- #define lb lower_bound
- #define ub upper_bound
- const ld PI = 3.141592653589793238462;
- const int MOD = 1e9 +7;
- const ll INF = 1e18;
- // if(abs(a-b)<eps) --> if(a==b)
- // fixed << setprecision(n) -->printing decimal till n
- // hypot(a ,b) --> sqrt(a^2 + b^2)
- using namespace std;
- void solve(){
- ll n,x,y,a;
- cin>>n>>x>>y>>a;
- ll total_shampoo =0;
- for(int i=0;i<a;i++){
- ll per;
- cin>>per;
- total_shampoo += per*10;
- }
- ll days_for_summer_break = n*14;
- total_shampoo -= (days_for_summer_break/y)*x;
- if(total_shampoo<0){
- cout<<-1<<endl;
- return;
- }
- ll remi = days_for_summer_break%y;
- if(remi==0 && total_shampoo>=0 && total_shampoo<x){
- cout<<0<<endl;
- }
- else{
- if(total_shampoo<x){
- cout<<-1<<endl;
- }
- else{
- ll ans = (total_shampoo/x)*y - remi;
- cout<<ans<<endl;
- }
- }
- }
- int main(){
- IO;
- ll t =1;
- cin>>t;
- while(t--){
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment