Codeforces Round #763 ABC 题解 (Java/C++)

A. Robot Cleaner

题解

按照题目要求模拟机器人的行为即可。

代码

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

题解

首先用一个map<int,set<int>>记录所有的区间,其中L是map的key,R记录在set中。然后对于每个区间我们枚举D,看看[L,D-1]和[D+1,R]是不是出现过即可。

代码

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

题解

二分搜索最终的结果。

然后从第n堆开始往第3堆依次检查。
对于当前正在检查的第i堆,我们把石头分为两类:1. 原本属于h[i]的,这一类可以分给i-1和i-2;2. 从i+1和i+2来的石头,我记为buff[i]。
如果h[i]+buff[i]加起来不足以满足结果,那么这个结果一定是过大了。否则我们就可以尽可能多的把h[i]分给i-1和i-2。

代码

Java

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

C++

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

D题纯数学,就是一个纯的无穷级数求和,太无聊了,毕竟马上就要春节了懒得做。

蜀ICP备19018968号