A masala uchun yechim:
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n, ans = 0, a, b;
cin >> n;
while (n --) {
cin >> a >> b;
ans += (a<24 && b>10000);
}
cout << ans;
}
signed main() {
ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int t = 1;
// cin >> t;
while (t --) {
solve();
cout << '\n';
}
return 0;
}
B masala uchun yechim:
shunchaki har bir tangadan nechtadan berishimiz kerakligini hisoblasak yetarli edi.
n = int(input())
ans = n // 10
n -= ans * 10
ans += n // 5
n -= (n // 5) * 5
ans += n // 3
n -= (n // 3) * 3
ans += n
print(ans)
C masala uchun yechim:
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n, q = 0;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; ++ i) {
cin >> arr[i];
if (arr[i]%2) q ++;
}
if (q == 0) cout << -1;
else {
int son;
sort(arr.begin(), arr.end());
for (int i = n - 1; i >= 0; -- i) {
if (arr[i]%2) {
if (q > 1) cout << arr[i];
else {
son = arr[i];
}
q --;
}
else cout << arr[i];
}
cout << son;
}
}
signed main() {
ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int t = 1;
// cin >> t;
while (t --) {
solve();
cout << '\n';
}
return 0;
}
D masala uchun yechim.
Bu yerda shunchaki shaharlar orasidagi maksimal masofa bomba yo`q qila oladigan rasiusdan kichik yoki yo`qligini tekshirishimiz kerak.
def solve(n, m, q, arr):
arr.append(0)
arr.append(n)
arr.sort()
jav = 0
for i in range(1, len(arr)):
jav = max(jav, arr[i] - arr[i - 1])
if jav <= m:
return "No"
else:
return "Yes"
n, m = map(int, input().split())
q = int(input())
arr = list(map(int, input().split()))
print(solve(n, m, q, arr))
E masala uchun yechim:
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n;
cin >> n;
vector<int> arr(n);
int ans = 0, son = 0;
for (int i = 0, x; i < n; ++ i) {
cin >> x;
son = max(son + x, x);
ans = max(ans, son);
}
cout << ans;
}
signed main() {
ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int t = 1;
// cin >> t;
while (t --) {
solve();
cout << '\n';
}
return 0;
}
F masala uchun yechim:
bu yerda shunchaki 1- va oxirgi hadlarini qo`shib 2 ga bo`lsak bo`ldi edi.
def solve(a, d, n):
an = a + (n - 1) * d
return (a + an) // 2
for _ in range(int(input())):
arr = list(map(str, input().split(",")))
a = int(arr[0])
b = int(arr[1])
n = int(input())
print(solve(a, (b - a), n))
G masala uchun yechim:
bunda men ikkilik sanoq sistemasidan foydalanib barcha kombinatsiyalarni ko`rib chiqib natijani topdim ko`pchilikka qulay bo`lishi uchun python dasturlash tilidan foydalandim
n = int(input())
arr = list(map(int, input().split()))
if n == 1:
print(arr[0])
exit()
son = 1
sonn = bin(son)[2:]
ans = []
jav = 108941294087189
son = 1
sonn = ('0' * (n - 1)) + '1'
while len(sonn) <= n:
son += 1
sonn = bin(son)[2:]
if len(sonn) < n:
sonn = ('0' * (n - len(sonn))) + sonn
qq = 0
for i in sonn:
qq += int(i)
if qq == n:
break
son1 = 0
son2 = 0
for j in range(n):
if sonn[j] == '0':
son1 += arr[j]
else:
son2 += arr[j]
q = abs(son1 - son2)
if jav > q:
jav = q
print(jav)
H masala uchun yechim:
n = int(input())
arr = list(map(int, input().split()))
bir = 0
ikki = 0
uch = 0
ans = 0
for i in arr:
if i == 1:
bir += 1
if i == 2:
ikki += 1
if i == 3:
uch += 1
if i == 4:
ans += 1
if uch >= bir:
ans += uch
bir = 0
else:
ans += uch
bir -= uch
ans += (ikki // 2)
ikki -= ((ikki // 2) * 2)
if bir + ikki > 0:
ans += (bir+(ikki*2)+3) // 4
print(ans)
Nimadir o`rgangan bo`lsangiz hursandman!