Codeforces Round #763 ABC Solutions (Java/C++)

A. Robot Cleaner

Solution:

Just simulate the behavior of the robot according to the requirements of the problem.

Code:

Java

Submission #142523532 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #142523730 - Codeforces
Codeforces. Programming competitions and contests, programming community

B. Game on Ranges

Solution:

First, use a map<int, set> to record all the ranges, where L is the key of the map, and R is recorded in the set. Then for each range, we enumerate D to see if [L, D-1] and [D+1, R] have appeared.

Code:

Java

Submission #142526780 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #142527262 - Codeforces
Codeforces. Programming competitions and contests, programming community

C. Balanced Stone Heaps

Solution:

Binary search final result.

Then check from the n-th heap to the 3rd heap in turn.
For the i-th heap currently under inspection, we divide the stones into two categories: 1. Originally belonging to h[i], this category can be assigned to i-1 and i-2; 2. The stones that come from i+1 and i+ 2, I record as buff[i].
If the sum of h[i]+buff[i] is not enough to satisfy the result, then the result must be too large. Otherwise we can divide h[i] into i-1 and i-2 as much as possible.

Code:

Java

Submission #142532944 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #142533049 - Codeforces
Codeforces. Programming competitions and contests, programming community

Question D is pure mathematics, which is a pure infinite series summation. It's too boring. After all, it's almost Chinese new year, so I'm too lazy to do it.

Show Comments
DigitalOcean Referral Badge