forked from imabhinav-am/Competetive-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcc_GUZAC.cpp
More file actions
48 lines (38 loc) · 707 Bytes
/
Copy pathcc_GUZAC.cpp
File metadata and controls
48 lines (38 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
Author : Abhinav
Modified : 19-08-2018 11:43:29 PM
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef map<ll,ll> mllmp;
#define faster ios_base::sync_with_stdio(false);cin.tie(0);
#define make_pair mp
const ll mod = 1e9+7;
#define rep(i,j,k) for(ll i=j; i<k; i++)
#define repv(i,j,k) for(ll i=j; i>k; i--)
int main(){
faster;
ll t,n,k,kt,x,tp,mx,mn,ans;
cin >> t;
while(t--){
cin >> n >> k >> x;
kt = k;
mn = INT_MAX;
mx = 0;
ans = 0;
vi tt;
while(kt--){
cin >> tp;
mx = max(tp,mx);
mn = min(tp,mn);
tt.emplace_back(tp);
ans += tp;
}
if(mx-mn==x)
mx--;
cout << ans << "\n";
}
return 0;
}