### danx's blog

By danx, history, 4 months ago,

Hello everyone!

Below is the editorial for the informatics division of CAMA along with the solution code to every problem. We have also uploaded PDFs with the editorial both in Spanish and English on our website. The contest can be found on this gym.

The problems were prepared by Esomer, danx, Hectorungo_18, javiergm06 and Rigobertus. We would also like to thank our VIP tester BernatP for his dedication towards the contest.

Solution
Code

Solution
Code

Solution
Code

Solution
Code

Solution
Code

Solution
Code

### G. XOR + Constructive = Love

First of all, we would like to apologize for misjudging the difficulty of this problem. It turned out to be much harder than what we expected.

Solution
Code

Solution
Code

Solution
Code

Solution
Code

Solution
Code

Solution
Code

Solution
Code

Solution
Code

Solution
Code

### P. Ski resort

Solution
Code
Tutorial of CAMA 2023
• +30

 » 4 months ago, # |   +9 We have put a lot of effort into preparing the contest and we believe that the problems are interesting. We hope you enjoy them!
•  » » 4 months ago, # ^ |   +5 I mean, I did prefer the math ones but yeah I guess!
 » 4 months ago, # |   +3 Problems are good. Nice contest!
•  » » 4 months ago, # ^ |   +5 Thanks, we are glad you like the problems. Hope to see you participating in the next edition :)
 » 4 months ago, # |   +9 K can be solved by without trees or compression, just by nuancing the two pointers approach. The idea is that when considering characters in non-increasing order of $a_i$, there is no point considering a character with a smaller $b_i$ than one we've seen already. Thus, we can impose both that $a_i$ is non-increasing and that $b_i$ is non-decreasing over the monsters that we consider, allowing us to use two pointers over $c$ and $d$ to maintain the number of coins as we go. Code#include #include #include #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; std::cin >> t; while (t--) { int n, m; std::cin >> n >> m; std::vector a(n), b(n); for (int i = 0; i < n; ++i) { std::cin >> b[i] >> a[i]; } std::vector c(m), d(m), e(m); for (int i = 0; i < m; ++i) { std::cin >> c[i] >> d[i] >> e[i]; } std::vector by_a(n); std::iota(by_a.begin(), by_a.end(), 0); std::sort(by_a.begin(), by_a.end(), [&](const int& i, const int& j) -> bool { return a[i] > a[j]; }); std::vector by_d(m); std::iota(by_d.begin(), by_d.end(), 0); std::sort(by_d.begin(), by_d.end(), [&](const int& i, const int& j) -> bool { return d[i] < d[j]; }); std::vector by_c(m); std::iota(by_c.begin(), by_c.end(), 0); std::sort(by_c.begin(), by_c.end(), [&](const int& i, const int& j) -> bool { return c[i] > c[j]; }); int prv_b = -1; int64_t ans = 0; int64_t sum = 0; std::vector present(m); std::vector bad(m); int di = 0, ci = 0; for (int char_index : by_a) { int cur_b = b[char_index]; if (cur_b <= prv_b) continue; prv_b = cur_b; while (di < m && d[by_d[di]] <= b[char_index]) { if (!bad[by_d[di]]) { present[by_d[di]] = true; sum += e[by_d[di]]; } di++; } while (ci < m && c[by_c[ci]] > a[char_index]) { bad[by_c[ci]] = true; if (present[by_c[ci]]) { present[by_c[ci]] = false; sum -= e[by_c[ci]]; } ci++; } ans = std::max(ans, sum); } std::cout << ans << '\n'; } } 
 » 3 months ago, # |   0 Is there a typo in the problem statement for problem E? Bounds claim N=5000 but test data goes above that
•  » » 3 months ago, # ^ |   0 Yes, sorry. It was meant to be $50000$, it seems we missed a $0$... It is now fixed.
•  » » » 3 months ago, # ^ |   +8 Thanks. Good problems!