-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcf.cpp
More file actions
134 lines (112 loc) · 2.91 KB
/
cf.cpp
File metadata and controls
134 lines (112 loc) · 2.91 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// #include <bits/stdc++.h>
// using namespace std;
// #define fastio ios::sync_with_stdio(false); cin.tie(0);
// #define ll long long
// #define pb push_back
// #define all(x) (x).begin(), (x).end()
// #define sz(x) ((int)(x).size())
// int main() {
// fastio;
// // Your code here
// int t;
// cin>>t;
// while(t--){
// int n;
// cin>>n;
// vector<int> a(n);
// int ans =0;
// for(int i=0; i<n;i++){
// cin>>a[i];
// }
// int c1 = 0, c0=0;
// for(int i=0; i<n; i++){
// if(a[i]==-1) c1++;
// else if(a[i]==0) c0++;
// }
// ans+=c0;
// if(c1%2==1) ans+=2;
// cout<<ans<<endl;
// }
// return 0;
// }
// #include <bits/stdc++.h>
// using namespace std;
// #define fastio ios::sync_with_stdio(false); cin.tie(0);
// #define ll long long
// #define pb push_back
// #define all(x) (x).begin(), (x).end()
// #define sz(x) ((int)(x).size())
// int main() {
// fastio;
// // Your code here
// int t;
// cin>>t;
// while(t--){
// ll n;
// cin>>n;
// vector<ll> a(n);
// ll ans =0;
// for(int i=0; i<n;i++){
// cin>>a[i];
// }
// if(n==2){
// cout<<abs(a[0]-a[1])<<endl;
// continue;
// }
// int ans1=0,ans2=0;
// sort(all(a));
// for(int i=0; i<n-1; i+=2){
// ans = max(ans, abs(a[i]-a[i+1]));
// }
// cout<<ans<<endl;
// }
// return 0;
// }
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
int main() {
fastio;
int t;
cin >> t;
while (t--) {
ll n, k;
cin >> n >> k;
vector<ll> a(n);
ll ans = 0;
int b1 = 0, b2 = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == k) b1++;
}
sort(all(a));
vector<int> present(k, 0);
for (int i = 0; i < n; i++) {
if (a[i] < k) present[a[i]] = 1;
}
for (int i = 0; i < k; i++) {
if (!present[i]) b2++;
}
if (k == n) ans = b2;
else ans = max(b1, b2);
cout << ans << '\n';
}
return 0;
}
if(i!=n-1 && (a[i][j-1]=='U') && p==0 && j-1 ) {
for(int k = j; k<n;k++){
a[i][k] = 'D';
}
f=1;
break;
}
else if(i==n-1 && a[i][j-1]=='U' && p==0 && j-1){
a[i][j] = 'R';
for(int k = j+1;k<n;k++){
a[i][k] = 'L';
}
}