Advertisement
swardiantara

Average Number

Feb 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int testCases, N, K, V;
  6.     scanf("%d",&testCases);
  7.     for(int i=0; i<testCases; i++) {
  8.         scanf("%d %d %d",&N, &K, &V);
  9.         int nSum=0, tempVal;
  10.         for(int j=0; j<N; j++) {
  11.             scanf("%d", &tempVal);
  12.             nSum += tempVal;
  13.         }
  14.        
  15.         int interVal = (V*(N+K) - nSum);
  16.        
  17.         if((interVal > 0) && (interVal % K == 0)) {
  18.             printf("%d\n",interVal/K);
  19.         }else {
  20.             printf("-1\n");
  21.         }
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement