Skip to content

Commit 7794e7f

Browse files
committed
CD R 926
1 parent 0d6f9cc commit 7794e7f

File tree

3 files changed

+311
-0
lines changed

3 files changed

+311
-0
lines changed

problemset/1929A.cpp

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
author: Ali
3+
Email: AliGhanbariCs@gmail.com
4+
GitHub: https://github.com/AliBinary
5+
created: 16.02.2024 17:48:13
6+
*/
7+
8+
#include <bits/stdc++.h>
9+
using namespace std;
10+
#pragma GCC optimize("Ofast,unroll-loops")
11+
#pragma GCC target("avx2,tune=native")
12+
#define fast_io ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
13+
14+
#define endl '\n'
15+
#define sep ' '
16+
typedef long long ll;
17+
typedef long double ld;
18+
typedef string str;
19+
20+
// pairs
21+
typedef pair<ll, ll> pll;
22+
typedef pair<int, int> pii;
23+
typedef pair<pii, int> ppi;
24+
typedef pair<int, pii> pip;
25+
typedef pair<pii, pii> ppp;
26+
#define F first
27+
#define S second
28+
#define mp make_pair
29+
30+
// vectors
31+
#define all(x) x.begin(), x.end()
32+
#define rall(x) x.rbegin(), x.rend()
33+
#define sz(x) int(x.size())
34+
#define pb push_back
35+
#define eb emplace_back
36+
37+
// loops
38+
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
39+
#define F0R(i, b) FOR(i, 0, b)
40+
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
41+
#define R0F(i, b) ROF(i, 0, b)
42+
#define rep(a) F0R(_, a)
43+
#define each(x, a) for (auto &x : a)
44+
45+
// debug
46+
#define debug(x) cerr << #x << '=' << (x) << endl;
47+
#define debugp(x) cerr << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
48+
#define debug2(x, y) cerr << "{" << #x << ", " << #y << "} = {" << (x) << ", " << (y) << "}" << endl;
49+
#define debugv(v) \
50+
{ \
51+
cerr << #v << " : "; \
52+
for (auto x : v) \
53+
cerr << x << ' '; \
54+
cerr << endl; \
55+
}
56+
#define wall cout << "----------------------------------------\n";
57+
58+
// etc.
59+
#define kill(x) return cout << x << endl, 0
60+
#define lc id << 1
61+
#define rc id << 1 | 1
62+
#define getbit(x, i) (((x) >> (i)) & 1)
63+
#define popcount(x) (__builtin_popcount(x))
64+
65+
bool cmp_pair(const pair<int, int> &a,
66+
const pair<int, int> &b)
67+
{
68+
return (a.second < b.second);
69+
}
70+
71+
void solve();
72+
int main()
73+
{
74+
fast_io;
75+
76+
int t = 1;
77+
cin >> t;
78+
while (t--)
79+
{
80+
solve();
81+
}
82+
83+
return 0;
84+
}
85+
86+
void solve()
87+
{
88+
int n;
89+
cin >> n;
90+
vector<ll> a(n);
91+
each(x, a)
92+
{
93+
cin >> x;
94+
}
95+
ll Max = a[0];
96+
ll Min = a[0];
97+
FOR(i, 1, n)
98+
{
99+
if (a[i] > Max)
100+
Max = a[i];
101+
if (a[i] < Min)
102+
Min = a[i];
103+
}
104+
cout << Max - Min << endl;
105+
}

problemset/1929B.cpp

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
author: Ali
3+
Email: AliGhanbariCs@gmail.com
4+
GitHub: https://github.com/AliBinary
5+
created: 16.02.2024 17:48:05
6+
*/
7+
8+
#include <bits/stdc++.h>
9+
using namespace std;
10+
#pragma GCC optimize("Ofast,unroll-loops")
11+
#pragma GCC target("avx2,tune=native")
12+
#define fast_io ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
13+
14+
#define endl '\n'
15+
#define sep ' '
16+
typedef long long ll;
17+
typedef long double ld;
18+
typedef string str;
19+
20+
// pairs
21+
typedef pair<ll, ll> pll;
22+
typedef pair<int, int> pii;
23+
typedef pair<pii, int> ppi;
24+
typedef pair<int, pii> pip;
25+
typedef pair<pii, pii> ppp;
26+
#define F first
27+
#define S second
28+
#define mp make_pair
29+
30+
// vectors
31+
#define all(x) x.begin(), x.end()
32+
#define rall(x) x.rbegin(), x.rend()
33+
#define sz(x) int(x.size())
34+
#define pb push_back
35+
#define eb emplace_back
36+
37+
// loops
38+
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
39+
#define F0R(i, b) FOR(i, 0, b)
40+
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
41+
#define R0F(i, b) ROF(i, 0, b)
42+
#define rep(a) F0R(_, a)
43+
#define each(x, a) for (auto &x : a)
44+
45+
// debug
46+
#define debug(x) cerr << #x << '=' << (x) << endl;
47+
#define debugp(x) cerr << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
48+
#define debug2(x, y) cerr << "{" << #x << ", " << #y << "} = {" << (x) << ", " << (y) << "}" << endl;
49+
#define debugv(v) \
50+
{ \
51+
cerr << #v << " : "; \
52+
for (auto x : v) \
53+
cerr << x << ' '; \
54+
cerr << endl; \
55+
}
56+
#define wall cout << "----------------------------------------\n";
57+
58+
// etc.
59+
#define kill(x) return cout << x << endl, 0
60+
#define lc id << 1
61+
#define rc id << 1 | 1
62+
#define getbit(x, i) (((x) >> (i)) & 1)
63+
#define popcount(x) (__builtin_popcount(x))
64+
65+
bool cmp_pair(const pair<int, int> &a,
66+
const pair<int, int> &b)
67+
{
68+
return (a.second < b.second);
69+
}
70+
71+
void solve();
72+
int main()
73+
{
74+
fast_io;
75+
76+
int t = 1;
77+
cin >> t;
78+
while (t--)
79+
{
80+
solve();
81+
}
82+
83+
return 0;
84+
}
85+
86+
void solve()
87+
{
88+
ll n, k;
89+
cin >> n >> k;
90+
ll ans;
91+
if (k <= 2 * n + 2 * (n - 2))
92+
ans = ceil(k * 1. / 2);
93+
else
94+
ans = 2 * n - (4 * n - 2 - k);
95+
cout << ans << endl;
96+
}

problemset/1929C.cpp

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
author: Ali
3+
Email: AliGhanbariCs@gmail.com
4+
GitHub: https://github.com/AliBinary
5+
created: 16.02.2024 17:47:55
6+
*/
7+
8+
#include <bits/stdc++.h>
9+
using namespace std;
10+
#pragma GCC optimize("Ofast,unroll-loops")
11+
#pragma GCC target("avx2,tune=native")
12+
#define fast_io ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
13+
14+
#define endl '\n'
15+
#define sep ' '
16+
typedef long long ll;
17+
typedef long double ld;
18+
typedef string str;
19+
20+
// pairs
21+
typedef pair<ll, ll> pll;
22+
typedef pair<int, int> pii;
23+
typedef pair<pii, int> ppi;
24+
typedef pair<int, pii> pip;
25+
typedef pair<pii, pii> ppp;
26+
#define F first
27+
#define S second
28+
#define mp make_pair
29+
30+
// vectors
31+
#define all(x) x.begin(), x.end()
32+
#define rall(x) x.rbegin(), x.rend()
33+
#define sz(x) int(x.size())
34+
#define pb push_back
35+
#define eb emplace_back
36+
37+
// loops
38+
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
39+
#define F0R(i, b) FOR(i, 0, b)
40+
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
41+
#define R0F(i, b) ROF(i, 0, b)
42+
#define rep(a) F0R(_, a)
43+
#define each(x, a) for (auto &x : a)
44+
45+
// debug
46+
#define debug(x) cerr << #x << '=' << (x) << endl;
47+
#define debugp(x) cerr << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
48+
#define debug2(x, y) cerr << "{" << #x << ", " << #y << "} = {" << (x) << ", " << (y) << "}" << endl;
49+
#define debugv(v) \
50+
{ \
51+
cerr << #v << " : "; \
52+
for (auto x : v) \
53+
cerr << x << ' '; \
54+
cerr << endl; \
55+
}
56+
#define wall cout << "----------------------------------------\n";
57+
58+
// etc.
59+
#define kill(x) return cout << x << endl, 0
60+
#define lc id << 1
61+
#define rc id << 1 | 1
62+
#define getbit(x, i) (((x) >> (i)) & 1)
63+
#define popcount(x) (__builtin_popcount(x))
64+
65+
bool cmp_pair(const pair<int, int> &a,
66+
const pair<int, int> &b)
67+
{
68+
return (a.second < b.second);
69+
}
70+
71+
void solve();
72+
int main()
73+
{
74+
fast_io;
75+
76+
int t = 1;
77+
cin >> t;
78+
while (t--)
79+
{
80+
solve();
81+
}
82+
83+
return 0;
84+
}
85+
86+
void solve()
87+
{
88+
int k, x;
89+
ll a;
90+
cin >> k >> x >> a;
91+
x++;
92+
93+
ll y[x] = {};
94+
ll sum = 1;
95+
y[0] = 1;
96+
97+
FOR(i, 1, x)
98+
{
99+
y[i] = sum / (k - 1);
100+
while (y[i] * (k - 1) <= sum)
101+
y[i]++;
102+
sum += y[i];
103+
if (sum > a)
104+
break;
105+
}
106+
if (a >= sum)
107+
cout << "YES" << endl;
108+
else
109+
cout << "NO" << endl;
110+
}

0 commit comments

Comments
 (0)