Codeforces Round 929 (Div. 3)

A. Turtle Puzzle: Rearrange and Negate 因为可以任意排列这个数组,并将一段区间内的数乘 $-1$,我们可以排序后把所有负数变为正数,即可 $code:$ void solve() { int n; std::cin >> n; int ans = 0; for(int i = 0, x; i < n; i ++ ) { std::cin >> x; ans += std::abs(x); } std::cout << ans << '\n'; } B. Turtle Math: Fast Three Task 分类讨论,$\sum_{i=1}^na_i\mod 3$ 等于 $0$ 的话不需要操作,等于 $1$ 就看有...

2024-12-1 · 3 分钟 · shift