We hope you enjoyed the contest! We revommend you to read all tutorials even if you solve the problem, maybe you will know something new.
Hint 1
Hint 2
Tutorial
Solution
Hint 1
Hint 2
Tutorial
Solution
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Global Round 19 Editorial
We hope you enjoyed the contest! We revommend you to read all tutorials even if you solve the problem, maybe you will know something new.
What happens if the array is already sorted?
What happens if there are two indexes $$$i$$$ and $$$j$$$, such that $$$i < h$$$ and $$$a_i > a_j$$$?
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int n;
cin >> n;
vector<int> a(n);
for (auto& u : a)
cin >> u;
if (!is_sorted(a.begin(), a.end()))
cout << "YES\n";
else
cout << "NO\n";
}
}
What is happening after replacing a segment of length greater than $$$1$$$ with segment of length $$$1$$$?
The cost of the arrays $$$b_1, b_2, \ldots, b_k$$$ equals to $$$k + \sum_{i=1}^{k}{mex({b_i})}$$$.
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int n;
cin >> n;
vector<int> a(n);
for (auto& u : a)
cin >> u;
int ans = 0;
for (int i = 0; i < n; i++) {
ans += (i + 1) * (n - i);
if (a[i] == 0)
ans += (i + 1) * (n - i);
}
cout << ans << '\n';
}
}
Rev. | Язык | Кто | Когда | Δ | Комментарий | |
---|---|---|---|---|---|---|
ru2 | Mangooste | 2022-02-12 22:56:07 | 596 | |||
en3 | Mangooste | 2022-02-12 22:43:20 | 2 | Tiny change: ' the arrays $b_1, b_2' -> ' the array $b_1, b_2' | ||
ru1 | Mangooste | 2022-02-12 22:42:23 | 13491 | Первая редакция перевода на Русский | ||
en2 | Mangooste | 2022-02-12 22:26:28 | 14538 | Tiny change: '_{i=1}^{k}{mex(\{b_i\})}$.\n</spoi' -> '_{i=1}^{k} mex(\{b_i\})$.\n</spoi' (published) | ||
en1 | Mangooste | 2022-02-12 20:36:55 | 1760 | Initial revision (saved to drafts) |
Название |
---|