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
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
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. | Lang. | By | When | Δ | Comment | |
---|---|---|---|---|---|---|
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) |
Name |
---|