Skip to content

Commit b170046

Browse files
committed
Resources
1 parent 750e95b commit b170046

21 files changed

+1141
-341
lines changed
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define ll long long int
4+
5+
void fastIO()
6+
{
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0);
9+
cout.tie(0);
10+
}
11+
12+
int main()
13+
{
14+
fastIO();
15+
int t;
16+
cin >> t;
17+
while (t--)
18+
{
19+
int a, b, c, d, e;
20+
cin >> a >> b >> c >> d >> e;
21+
if (a + b <= d && c <= e)
22+
{
23+
cout << "YES";
24+
}
25+
else if (b + c <= d && a <= e)
26+
{
27+
cout << "YES";
28+
}
29+
else if (c + a <= d && b <= e)
30+
{
31+
cout << "YES";
32+
}
33+
else
34+
{
35+
cout << "NO";
36+
}
37+
cout << "\n";
38+
}
39+
return 0;
40+
}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define ll long long int
4+
5+
void fastIO()
6+
{
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0);
9+
cout.tie(0);
10+
}
11+
12+
int main()
13+
{
14+
fastIO();
15+
int t;
16+
cin >> t;
17+
while (t--)
18+
{
19+
int n, ele, even = 0, odd = 0;
20+
cin >> n;
21+
for (int i = 0; i < n; ++i)
22+
{
23+
cin >> ele;
24+
if (ele % 2 == 0)
25+
{
26+
even++;
27+
}
28+
else
29+
{
30+
odd++;
31+
}
32+
}
33+
int even1 = n / 2, odd1 = n / 2 + n % 2;
34+
int ans = min(even, odd1) + min(odd, even1);
35+
cout << ans << "\n";
36+
}
37+
return 0;
38+
}

Codechef/Contests/Travel_Pass.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define ll long long int
4+
5+
void fastIO()
6+
{
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0);
9+
cout.tie(0);
10+
}
11+
12+
int main()
13+
{
14+
fastIO();
15+
int t;
16+
cin >> t;
17+
while (t--)
18+
{
19+
int n, a, b;
20+
string str;
21+
cin >> n >> a >> b;
22+
cin >> str;
23+
int arr[2] = {0};
24+
for (int i = 0; i < n; ++i)
25+
{
26+
// arr[int(str[i])]++;
27+
if (str[i] == '0')
28+
{
29+
arr[0]++;
30+
}
31+
else
32+
{
33+
arr[1]++;
34+
}
35+
}
36+
int ans = (arr[0] * a) + (arr[1] * b);
37+
cout << ans << "\n";
38+
}
39+
return 0;
40+
}

Codechef/Contests/XOR_Equal.cpp

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define ll long long int
4+
5+
void fastIO()
6+
{
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0);
9+
cout.tie(0);
10+
}
11+
12+
int main()
13+
{
14+
fastIO();
15+
int t;
16+
cin >> t;
17+
while (t--)
18+
{
19+
int n, a;
20+
cin >> n >> a;
21+
unordered_map<int, int> mp;
22+
vector<int> v;
23+
24+
for (int i = 0; i < n; ++i)
25+
{
26+
int ele = 0;
27+
cin >> ele;
28+
v.push_back(ele);
29+
mp[ele]++;
30+
}
31+
32+
int ans = 0, mini = 0;
33+
for (auto it : v)
34+
{
35+
if ((it != it ^ a) && ans < mp[it] + mp[it ^ a])
36+
{
37+
ans = mp[it] + mp[it ^ a];
38+
mini = mp[it ^ a];
39+
}
40+
else if ((it != it ^ a) && (ans == mp[it] + mp[it ^ a]) && (mini > mp[it ^ a]))
41+
{
42+
ans = mp[it] + mp[it ^ a];
43+
mini = mp[it ^ a];
44+
}
45+
else if (ans < mp[it])
46+
{
47+
ans = mp[it];
48+
mini = 0;
49+
}
50+
}
51+
cout << ans << " " << mini << "\n";
52+
}
53+
return 0;
54+
}

0 commit comments

Comments
 (0)