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 | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
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) |
Название |
---|