fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. int T;
  9. cin >> T;
  10.  
  11. while (T--) {
  12. int N, X, Y;
  13. cin >> N >> X >> Y;
  14.  
  15. vector<int> A(N);
  16. for (int i = 0; i < N; ++i) {
  17. cin >> A[i];
  18. }
  19.  
  20. int cost = 0;
  21. if (X > Y) {
  22. cost = N * Y;
  23. } else {
  24. int max_difficulty = *max_element(A.begin(), A.end());
  25. cost = (N - 1) * X + Y;
  26. }
  27.  
  28. cout << cost << endl;
  29. }
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 5300KB
stdin
3
4 5 30
4 5 2 3
4 5 30
4 7 2 3
5 3 100
11 23 35 47 59
stdout
45
45
112