-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcf1036hack.cpp
52 lines (49 loc) · 1.1 KB
/
cf1036hack.cpp
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
49
50
51
52
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define all(a) (a).begin(),(a).end()
#define x first
#define y second
#define sz(x) (int)x.size()
#define endl '\n'
#define hell 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
void solve(){
ll n,m,k;
cin>>n>>m>>k;
ll reqd=max(n,m);
if(k<reqd){
cout<<-1<<endl;
return;
}
ll d=max(m,n)-min(m,n);
k-=min(m,n);
if(d%2==0){
cout<<min(m,n)+k-2*(k%2)<<endl;
//if k - min(m,n) is even ans is k else k - 2
}
else{
cout<<min(m,n)+k-1<<endl;
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t=1;
cin>>t;
while(t--){
solve();
}
return 0;
}