Skip to content

Commit 692abda

Browse files
authored
Add files via upload
1 parent 26b815a commit 692abda

23 files changed

+1377
-0
lines changed

Ultra-Fast Mathematician.cpp

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// https://codeforces.com/contest/61/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+
string a, b;
57+
cin >> a >> b;
58+
fori(0, a.size())
59+
if (a[i] == b[i])
60+
cout << 0;
61+
else
62+
cout << 1;
63+
64+
return 0;
65+
}

Unique Bid Auction.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
for _ in range(int(input())):
2+
n = int(input())
3+
arr = list(map(int, input().split()))
4+
dic = {}
5+
for i in range(n):
6+
dic[arr[i]] = 1 + dic.setdefault(arr[i], 0)
7+
ne = list(sorted(dic))
8+
i = 0
9+
flag = False
10+
while i < len(ne):
11+
if dic[ne[i]] == 1:
12+
print(arr.index(ne[i]) + 1)
13+
flag = True
14+
break
15+
else:
16+
i += 1
17+
if not flag:
18+
print(-1)

Valerii Against Everyone.cpp

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// https://codeforces.com/contest/1438/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;
61+
cin >> n;
62+
vll arr(n);
63+
fori(0, n)
64+
cin >> arr[i];
65+
bool flag = true;
66+
fori(0, n) {
67+
if (count(all(arr), arr[i]) > 1) {
68+
flag = false;
69+
cout << "YES\n";
70+
break;
71+
}
72+
}
73+
if (flag)
74+
cout << "NO\n";
75+
}
76+
77+
return 0;
78+
}

Vasya and Coins.cpp

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// https://codeforces.com/contest/1660/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<ll, ll>
28+
#define vll vector<long long>
29+
#define vpll vector<pll>
30+
#define mll map<ll, ll>
31+
#define sz(x) ((int) x.size())
32+
#define inf 1e18
33+
#define que_max priority_queue<ll>
34+
#define que_min priority_queue <ll, vll, greater<ll>>
35+
#define gcd(a, b) __gcd(a, b)
36+
#define range(a,b) substr(a,b-a+1)
37+
#define setbits(x) __builtin_popcountll(x)
38+
#define zrobits(x) __builtin_ctzll(x)
39+
#define fori(a, n) for (ll i = a; i < n; i++)
40+
#define forj(a, n) for (ll j = a; j < n; j++)
41+
#define fork(a, n) for (ll k = a; k < n; k++)
42+
#define print(x) for (auto i : x) cout << i << " "; cout << "\n";
43+
#define print1(x) for (auto i : x) cout << i.fi << " " << i.se << "\n";
44+
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
45+
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
46+
47+
inline ll power(ll a, ll b)
48+
{
49+
ll x = 1;
50+
while (b) {
51+
if (b & 1)
52+
x *= a;
53+
a *= a;
54+
b >>= 1;
55+
}
56+
return x;
57+
}
58+
59+
template <class T>
60+
bool comp(T a, T b) {
61+
if (a < b)
62+
return true;
63+
return false;
64+
}
65+
66+
void solve() {
67+
ll a, b;
68+
cin >> a >> b;
69+
if (a == 0)
70+
cout << 1 << "\n";
71+
else
72+
cout << 2 * b + a + 1 << "\n";
73+
}
74+
75+
int32_t main()
76+
{
77+
FIO;
78+
79+
#ifndef ONLINE_JUDGE
80+
//remove this piece of code when this has to be submitted in kickstart, coding ninjas
81+
freopen("input.txt", "r", stdin);
82+
freopen("output.txt", "w", stdout);
83+
//freopen is used to associate a file with stdin or stdout stream in C++
84+
#endif
85+
86+
clock_t z = clock();
87+
88+
ll t = 1;
89+
cin >> t;
90+
while (t--) {
91+
solve();
92+
}
93+
94+
cerr << "Run Time: " << ((double)(clock() - z) / CLOCKS_PER_SEC) << "\n";
95+
96+
return 0;
97+
}
98+

Vika and Squares.cpp

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// https://codeforces.com/contest/610/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 n, ans = 0;
58+
cin >> n;
59+
vll arr(n);
60+
fori(0, n)
61+
cin >> arr[i];
62+
auto i = min_element(all(arr));
63+
ll j = i - arr.begin();
64+
ll gg;
65+
while (j < n) {
66+
ll temp = 0;
67+
while (j < n && arr[j] != *i) {
68+
j++;
69+
temp++;
70+
}
71+
if (temp > ans)
72+
ans = temp;
73+
j++;
74+
gg = temp;
75+
}
76+
j = 0;
77+
while (arr[n - 1] != *i && arr[j] != *i) {
78+
j++;
79+
gg++;
80+
}
81+
if (gg > ans)
82+
ans = gg;
83+
j = 0;
84+
if (arr[n - 1] == *i) {
85+
while (j < n && arr[j] != *i)
86+
j++;
87+
if (j > ans)
88+
ans = j;
89+
}
90+
cout << *i * n + ans;
91+
return 0;
92+
}

0 commit comments

Comments
 (0)