Skip to content

Commit 36b03af

Browse files
authored
Add files via upload
1 parent 80ca6b5 commit 36b03af

28 files changed

+1637
-0
lines changed

Bad Triangle.cpp

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// https://codeforces.com/contest/1398/problem/A
2+
/*
3+
4+
░██████╗██████╗░░█████╗░██████╗░░██████╗██╗░░██╗  ░██████╗░██╗░░░██╗██████╗░████████╗░█████╗░
5+
██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝██║░░██║  ██╔════╝░██║░░░██║██╔══██╗╚══██╔══╝██╔══██╗
6+
╚█████╗░██████╔╝███████║██████╔╝╚█████╗░███████║  ██║░░██╗░██║░░░██║██████╔╝░░░██║░░░███████║
7+
░╚═══██╗██╔═══╝░██╔══██║██╔══██╗░╚═══██╗██╔══██║  ██║░░╚██╗██║░░░██║██╔═══╝░░░░██║░░░██╔══██║
8+
██████╔╝██║░░░░░██║░░██║██║░░██║██████╔╝██║░░██║  ╚██████╔╝╚██████╔╝██║░░░░░░░░██║░░░██║░░██║
9+
╚═════╝░╚═╝░░░░░╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░╚═╝░░╚═╝  ░╚═════╝░░╚═════╝░╚═╝░░░░░░░░╚═╝░░░╚═╝░░╚═╝
10+
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
11+
█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗
12+
╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝
13+
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
14+
15+
*/
16+
17+
#include <bits/stdc++.h>
18+
19+
using namespace std;
20+
21+
#define fi first
22+
#define se second
23+
#define pb push_back
24+
#define mp make_pair
25+
#define all(x) x.begin(), x.end()
26+
#define ll long long
27+
#define pll pair<long, long>
28+
#define vll vector<long long>
29+
#define inf 1e18
30+
#define setbits(x) __builtin_popcountll(x)
31+
#define gcd(a, b) __gcd(a, b)
32+
#define range(a,b) substr(a,b-a+1)
33+
#define fori(a, n) for (ll i = a; i < n; i++)
34+
#define forj(a, n) for (ll j = a; j < n; j++)
35+
#define fork(a, n) for (ll k = a; k < n; k++)
36+
#define print(x) for (auto i : x) {cout << i << " ";}
37+
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
38+
39+
template <class T>
40+
bool comp(T a, T b) {
41+
if (a < b)
42+
return true;
43+
return false;
44+
}
45+
46+
int main()
47+
{
48+
FIO;
49+
50+
#ifndef ONLINE_JUDGE
51+
//remove this piece of code when this has to be submitted in kickstart, coding ninjas
52+
freopen("input.txt", "r", stdin);
53+
freopen("output.txt", "w", stdout);
54+
//freopen is used to associate a file with stdin or stdout stream in C++
55+
#endif
56+
57+
ll t;
58+
cin >> t;
59+
while (t--) {
60+
ll n, suma = 0;
61+
cin >> n;
62+
vll arr(n);
63+
fori(0, n)
64+
cin >> arr[i];
65+
if (arr[0] + arr[1] <= arr[n - 1])
66+
cout << 1 << " " << 2 << " " << n << "\n";
67+
else
68+
cout << -1 << "\n";
69+
}
70+
71+
return 0;
72+
}

Barrels.cpp

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// https://codeforces.com/contest/1430/problem/B
2+
/*
3+
4+
░██████╗██████╗░░█████╗░██████╗░░██████╗██╗░░██╗  ░██████╗░██╗░░░██╗██████╗░████████╗░█████╗░
5+
██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝██║░░██║  ██╔════╝░██║░░░██║██╔══██╗╚══██╔══╝██╔══██╗
6+
╚█████╗░██████╔╝███████║██████╔╝╚█████╗░███████║  ██║░░██╗░██║░░░██║██████╔╝░░░██║░░░███████║
7+
░╚═══██╗██╔═══╝░██╔══██║██╔══██╗░╚═══██╗██╔══██║  ██║░░╚██╗██║░░░██║██╔═══╝░░░░██║░░░██╔══██║
8+
██████╔╝██║░░░░░██║░░██║██║░░██║██████╔╝██║░░██║  ╚██████╔╝╚██████╔╝██║░░░░░░░░██║░░░██║░░██║
9+
╚═════╝░╚═╝░░░░░╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░╚═╝░░╚═╝  ░╚═════╝░░╚═════╝░╚═╝░░░░░░░░╚═╝░░░╚═╝░░╚═╝
10+
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
11+
█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗
12+
╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝
13+
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
14+
15+
*/
16+
17+
#include <bits/stdc++.h>
18+
19+
using namespace std;
20+
21+
#define fi first
22+
#define se second
23+
#define pb push_back
24+
#define mp make_pair
25+
#define all(x) x.begin(), x.end()
26+
#define ll long long
27+
#define pll pair<long, long>
28+
#define vll vector<long long>
29+
#define inf 1e18
30+
#define setbits(x) __builtin_popcountll(x)
31+
#define gcd(a, b) __gcd(a, b)
32+
#define range(a,b) substr(a,b-a+1)
33+
#define fori(a, n) for (ll i = a; i < n; i++)
34+
#define forj(a, n) for (ll j = a; j < n; j++)
35+
#define fork(a, n) for (ll k = a; k < n; k++)
36+
#define print(x) for (auto i : x) {cout << i << " ";}
37+
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
38+
39+
template <class T>
40+
bool comp(T a, T b) {
41+
if (a < b)
42+
return true;
43+
return false;
44+
}
45+
46+
int main()
47+
{
48+
FIO;
49+
50+
#ifndef ONLINE_JUDGE
51+
//remove this piece of code when this has to be submitted in kickstart, coding ninjas
52+
freopen("input.txt", "r", stdin);
53+
freopen("output.txt", "w", stdout);
54+
//freopen is used to associate a file with stdin or stdout stream in C++
55+
#endif
56+
57+
ll t;
58+
cin >> t;
59+
while (t--) {
60+
ll n, k;
61+
cin >> n >> k;
62+
vll arr(n);
63+
fori(0, n)
64+
cin >> arr[i];
65+
sort(all(arr), greater<ll>());
66+
ll i = 1;
67+
while (k > 0 && i < n) {
68+
k--;
69+
arr[0] += arr[i++];
70+
}
71+
cout << arr[0] << "\n";
72+
}
73+
74+
return 0;
75+
}

Bear and Big Brother.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// https://codeforces.com/problemset/problem/791/A
2+
#include <bits/stdc++.h>
3+
4+
#define fi first
5+
#define se second
6+
#define pb push_back
7+
#define mp make_pair
8+
#define ll long long
9+
#define pll pair<long, long>
10+
#define vll vector<long long>
11+
#define inf 1e18
12+
#define range(a,b) substr(a,b-a+1)
13+
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
14+
15+
using namespace std;
16+
17+
int main()
18+
{
19+
FIO;
20+
21+
#ifndef ONLINE_JUDGE
22+
freopen("input.txt", "r", stdin);
23+
freopen("output.txt", "w", stdout);
24+
#endif
25+
26+
ll a, b;
27+
cin >> a >> b;
28+
ll i = 0;
29+
while (a <= b)
30+
{
31+
i++;
32+
a *= 3;
33+
b *= 2;
34+
}
35+
cout << i;
36+
37+
38+
return 0;
39+
}

Beautiful Matrix.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// https://codeforces.com/problemset/problem/263/A
2+
#include <bits/stdc++.h>
3+
4+
#define fi first
5+
#define se second
6+
#define pb push_back
7+
#define mp make_pair
8+
#define ll long long
9+
#define pll pair<long, long>
10+
#define vll vector<long long>
11+
#define inf 1e18
12+
#define range(a,b) substr(a,b-a+1)
13+
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
14+
15+
using namespace std;
16+
17+
int main()
18+
{
19+
FIO;
20+
21+
#ifndef ONLINE_JUDGE
22+
freopen("input.txt", "r", stdin);
23+
freopen("output.txt", "w", stdout);
24+
#endif
25+
26+
ll arr[6][6], temp;
27+
for (int i = 1; i < 6; i++) {
28+
for (int j = 1; j < 6; j++) {
29+
cin >> temp;
30+
if (temp) {
31+
cout << (abs(j - 3) + abs(i - 3));
32+
break;
33+
}
34+
}
35+
}
36+
37+
return 0;
38+
}

Beautiful Year.cpp

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// https://codeforces.com/contest/271/problem/A
2+
#include <bits/stdc++.h>
3+
4+
using namespace std;
5+
6+
#define fi first
7+
#define se second
8+
#define pb push_back
9+
#define mp make_pair
10+
#define all(x) x.begin(), x.end()
11+
#define ll long long
12+
#define pll pair<long, long>
13+
#define vll vector<long long>
14+
#define inf 1e18
15+
#define gcd(a, b) __gcd(a, b)
16+
#define range(a,b) substr(a,b-a+1)
17+
#define fori(a, n) for (ll i = a; i < n; i++)
18+
#define forj(a, n) for (ll j = a; j < n; j++)
19+
#define fork(a, n) for (ll k = a; k < n; k++)
20+
#define print(x) for (auto i : x) {cout << i << " ";}
21+
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
22+
23+
template <class T>
24+
bool comp(T a, T b) {
25+
if (a < b)
26+
return true;
27+
return false;
28+
}
29+
30+
bool ans(ll t)
31+
{
32+
string s = to_string(t);
33+
if (count(all(s), s[0]) > 1)
34+
return false;
35+
if (count(all(s), s[1]) > 1)
36+
return false;
37+
if (count(all(s), s[2]) > 1)
38+
return false;
39+
return true;
40+
}
41+
42+
int main()
43+
{
44+
FIO;
45+
46+
#ifndef ONLINE_JUDGE
47+
//remove this piece of code when this has to be submitted in kickstart, coding ninjas
48+
freopen("input.txt", "r", stdin);
49+
freopen("output.txt", "w", stdout);
50+
//freopen is used to associate a file with stdin or stdout stream in C++
51+
#endif
52+
53+
ll t;
54+
cin >> t;
55+
while (!ans(++t)) {}
56+
cout << t;
57+
58+
return 0;
59+
}

Bicycle Chain.cpp

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// https://codeforces.com/contest/215/problem/A
2+
/*
3+
4+
░██████╗██████╗░░█████╗░██████╗░░██████╗██╗░░██╗  ░██████╗░██╗░░░██╗██████╗░████████╗░█████╗░
5+
██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝██║░░██║  ██╔════╝░██║░░░██║██╔══██╗╚══██╔══╝██╔══██╗
6+
╚█████╗░██████╔╝███████║██████╔╝╚█████╗░███████║  ██║░░██╗░██║░░░██║██████╔╝░░░██║░░░███████║
7+
░╚═══██╗██╔═══╝░██╔══██║██╔══██╗░╚═══██╗██╔══██║  ██║░░╚██╗██║░░░██║██╔═══╝░░░░██║░░░██╔══██║
8+
██████╔╝██║░░░░░██║░░██║██║░░██║██████╔╝██║░░██║  ╚██████╔╝╚██████╔╝██║░░░░░░░░██║░░░██║░░██║
9+
╚═════╝░╚═╝░░░░░╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░╚═╝░░╚═╝  ░╚═════╝░░╚═════╝░╚═╝░░░░░░░░╚═╝░░░╚═╝░░╚═╝
10+
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
11+
█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗█████╗
12+
╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝╚════╝
13+
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
14+
15+
*/
16+
17+
#include <bits/stdc++.h>
18+
19+
using namespace std;
20+
21+
#define fi first
22+
#define se second
23+
#define pb push_back
24+
#define mp make_pair
25+
#define all(x) x.begin(), x.end()
26+
#define ll long long
27+
#define pll pair<long, long>
28+
#define vll vector<long long>
29+
#define inf 1e18
30+
#define gcd(a, b) __gcd(a, b)
31+
#define range(a,b) substr(a,b-a+1)
32+
#define fori(a, n) for (ll i = a; i < n; i++)
33+
#define forj(a, n) for (ll j = a; j < n; j++)
34+
#define fork(a, n) for (ll k = a; k < n; k++)
35+
#define print(x) for (auto i : x) {cout << i << " ";}
36+
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
37+
38+
template <class T>
39+
bool comp(T a, T b) {
40+
if (a < b)
41+
return true;
42+
return false;
43+
}
44+
45+
int main()
46+
{
47+
FIO;
48+
49+
#ifndef ONLINE_JUDGE
50+
//remove this piece of code when this has to be submitted in kickstart, coding ninjas
51+
freopen("input.txt", "r", stdin);
52+
freopen("output.txt", "w", stdout);
53+
//freopen is used to associate a file with stdin or stdout stream in C++
54+
#endif
55+
56+
ll n;
57+
cin >> n;
58+
vll arr(n);
59+
fori(0, n)
60+
cin >> arr[i];
61+
sort(all(arr));
62+
ll m;
63+
cin >> m;
64+
vll srr(m);
65+
fori(0, m)
66+
cin >> srr[i];
67+
sort(all(srr), greater<ll>());
68+
map <ll, ll> ans;
69+
fori(0, n)
70+
forj(0, m)
71+
if (srr[j] % arr[i] == 0)
72+
if (ans.find(srr[j] / arr[i]) != ans.end())
73+
ans[srr[j] / arr[i]]++;
74+
else
75+
ans.insert({srr[j] / arr[i], 1});
76+
for (auto i = ans.rbegin(); i != ans.rend(); i++) {
77+
cout << i->second << "\n";
78+
break;
79+
}
80+
return 0;
81+
}

0 commit comments

Comments
 (0)