Editorial for #1 Round for Beginners (Div. 4)
$$$A.$$$ Coins for friends
Authors: zhasurr, round-for-beginners
The most optimal solution was $$$n$$$ + $$$1$$$. Perfect can give each friend $$$1$$$ coins and he himself will get $$$1$$$ coin.
(C++) Author's solution:#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
cout << n + 1;
return 0;
}
(Python) Tester's solution:n = int(input())
print(n + 1)
$$$B.$$$ Road to be Legend
Authors: zhasurr, round-for-beginners, abdu11a
First, take a separate value that will read the lessons and the value that will store the largest. Check yesterday's lesson is the same as today's. If not, then increase the value and the value that stores the longest days will be equal to the maximum of these two values, otherwise the value is equal to $$$1$$$. At the end, check the two values again and print the value that stores the largest
(C++) Author's solution:#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
string s;
cin >> s;
int ans = 0, k = 1;
for(int i = 1; i < n; i++){
if(s[i] != s[i - 1]) k++;
else{
ans = max(ans, k);
k = 1;
}
}
ans = max(ans, k);
cout << ans;
return 0;
}
(Python) Tester's solution:n = int(input())
arr = input()
best = 0
cnt = 0
for i in range(n - 1):
if arr[i] != arr[i + 1]:
cnt += 1
else:
best = max(best, cnt)
cnt = 0
print(max(cnt + 1, best + 1))
$$$C.$$$ Pair of numbers
Authors: zhasurr
If the sum of all numbers in the array is odd, then NO is displayed exactly. Otherwise, take a single number that is equal to $$$sum$$$/$$$2$$$. Sort the array. Now it is exactly guaranteed that the penultimate number and $$$a_i$$$ will be equal to $$$sum$$$/$$$2$$$ or when $$$a_i$$$ + $$$a_{i + 1}$$$ will be equal to $$$sum$$$/$$$2$$$
(C++) Author's solution:#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll n;
cin >> n;
ll a[n];
ll sum = 0;
for (ll i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
if (sum % 2 == 1) {
cout << "NO";
return 0;
}
sort(a, a + n);
ll sm = sum / 2;
for (ll i = 0; i < n - 1; i++) {
if (a[i] + a[n - 1] == sm || a[i] + a[i + 1] == sm) {
cout << "YES";
return 0;
}
}
cout << "NO";
return 0;
}
(Python) Tester's solution:from collections import defaultdict
n = int(input())
arr = list(map(int,input().split()))
s = sum(arr)
if s%2 != 0:
print("NO")
exit()
s = s//2
d = defaultdict(int)
for i in arr:
d[i] += 1
for i in range(n):
if s < arr[i]:
continue
if s - arr[i] == arr[i]:
if d[arr[i]] > 1:
print("YES")
break
else:
if d[s - arr[i]]!=0:
print("YES")
break
else:
print("NO")
$$$D.$$$ Permutation
The task was taken from the 3rd stage of the Republican Olympiad 2020 (Kazakhstan)

The first number that is odd will jump two steps forward, i.e. the 1st number will become 3 and the 3 will jump the next two numbers and will equal 5. With the even ones everything is the same. For example, the number 2 will be equal to 4, and the 4th to 6, etc.
(C++) Author's solution:#include <bits/stdc++.h>
using namespace std;
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
int main() {
speed;
ll n;
cin >> n;
ll a[n + 1];
for (ll i = 1; i <= n; i++) {
if(i % 2 != 0) a[i] = i + 2;
else a[i] = i - 2;
}
if (n % 2 != 0) a[n] = n - 1;
else a[n - 1] = n;
a[2] = 1;
for (ll i = 1; i <= n; i++) cout << a[i] << ' ';
}
(Python) Tester's solution:n = int(input())
arr = [i for i in range(2, n + 1)]
arr.append(1)
print(*arr)
$$$E.$$$ Joyful numbers
Author: round-for-beginners
(C++) Author's solution:#include <iostream>
using namespace std;
int main() {
long long int n;
cin >> n;
cout << ((n - 1) * 10 + 5) * ((n - 1) * 10 + 5);
return 0;
}
(Python) Tester's solution:k = int(input())
print(((k - 1) * 10 + 5) ** 2)
UPD1: Searching for testers to new rounds. If you want to be tester write message to this mail: [email protected]
python codes plz
added :)
Can someone please clarify problem C? Why is it guaranteed that "the penultimate number and ai will be equal to sum/2 or when ai + ai+1 will be equal to sum/2" when the array is sorted?
example: n = 5; array = 1 3 7 6 5
sort and get an array 1 3 5 6 7
loop through the array and check the number with the last element and the next element.
Thanks!
enjoy this a lot
I have no idea why my solution exactly coincides with tester's python solution instead of this that I was not a tester. C A D :)
I'm sorry I don't understand python and I had to take your code
No worry, I was just joking. :)
I am not able to see other's code.
How can I participate(is it possible?) in a contest like this?