Advertisement
deadwing97

AVG Editorialist

Feb 23rd, 2019
1,688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7.     int T;
  8.     cin>>T;
  9.     while(T--){
  10.  
  11.         long long N , K , V , S = 0;
  12.         cin>>N>>K>>V;
  13.         for(int j = 1 ; j <= N ; j++){
  14.             int x;
  15.             cin>>x;
  16.             S += x;
  17.         }
  18.         if( (V * (N+K)- S)%K ) puts("-1");
  19.         else{
  20.             long long ans = (V * (N+K)- S)/K;
  21.             if(ans <= 0) ans = -1;
  22.             cout<<ans<<endl;
  23.         }
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement