-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2107b.cpp
More file actions
41 lines (35 loc) · 1.04 KB
/
2107b.cpp
File metadata and controls
41 lines (35 loc) · 1.04 KB
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
#include <bits/stdc++.h>
using namespace std;
#define TOM cout<<"Tom\n"
#define JERRY cout<<"Jerry\n"
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef set<int> si;
int main() {
int _; cin >> _;
while(_--) {
int a,b; cin >> a >> b;
vi boxes(a);
for(int i = 0; i < a; i++) cin >> boxes[i];
int maxim = boxes[0], minim = boxes[0], sum=0;
int maxim_count=0;
for(auto k : boxes) {
if(maxim < k) {
maxim = k;
maxim_count=1;
} else if(maxim == k) maxim_count++;
minim = min(k, minim);
sum+=k;
}
if(maxim-minim > b+1 || (maxim_count>1 && maxim-minim>b)) JERRY;
else {
if (sum%2) TOM;
else JERRY;
}
}
return 0;
}