A. Lineland Mail
Problem Description:
All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordinate on the Ox axis. No two cities are located at a single point.
Lineland residents love to send letters to each other. A person may send a letter only if the recipient lives in another city (because if they live in the same city, then it is easier to drop in).
Strange but true, the cost of sending the letter is exactly equal to the distance between the sender’s city and the recipient’s city.
For each city calculate two values ??mini and maxi, where mini is the minimum cost of sending a letter from the i-th city to some other city, and maxi is the the maximum cost of sending a letter from the i-th city to some other city
#include
#include
#include
#include
#include
#include
#include
#include
#include
B. Berland National Library
Problem Description:
Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.
Today was the pilot launch of an automated reading room visitors’ accounting system! The scanner of the system is installed at the entrance to the reading room. It records the events of the form “reader entered room”, “reader left room”. Every reader is assigned a registration number during the registration procedure at the library — it’s a unique integer from 1 to 106. Thus, the system logs events of two forms:
“+ ri” — the reader with registration number ri entered the room;
“- ri” — the reader with registration number ri left the room.
The first launch of the system was a success, it functioned for some period of time, and, at the time of its launch and at the time of its shutdown, the reading room may already have visitors.
Significant funds of the budget of Berland have been spent on the design and installation of the system. Therefore, some of the citizens of the capital now demand to explain the need for this system and the benefits that its implementation will bring. Now, the developers of the system need to urgently come up with reasons for its existence.
Help the system developers to find the minimum possible capacity of the reading room (in visitors) using the log of the system available to you.
题意:
图书馆阅读室门口有个能记录有人进出的机器.
给你一段记录,可能开始记录的时候里边还有人
问你这个阅读室最少能容纳多少人
思路:
把没记录进去但记录过出去的人加在最开始就行了
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
C. Geometric Progression
Problem Description:
【Codeforces Round #Pi (Div. 2) A~D 题解B C D】Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subsequences of length three can be selected from a, so that they form a geometric progression with common ratio k.
A subsequence of length three is a combination of three such indexes i1,?i2,?i3, that 1?≤?i1? A geometric progression with common ratio k is a sequence of numbers of the form b·k0,?b·k1,?…,?b·kr?-?1.
Polycarp is only three years old, so he can not calculate this number himself. Help him to do it.
题意:
给你一段长度为n的序列,让你从中选三个递增的数
这三个数必须满足b*k^t,b*k^(t+1),b*k^(t+2)
问能选出多少组这样的数
思路:
特判一下k==1的情况和x==0的情况
然后就行dp
dp[i][j][k]代表b==i,t==j并且是这三个数的第k个数有多少种情况
dp[i][j][1]++
dp[i][j][2]+=dp[i][j-1][1]
ans+=dp[i][j-1][2]就能得到答案了
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
D. One-Dimensional Battle Ships
Problem Description:
Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1?×?n table).
At the beginning of the game Alice puts k ships on the field without telling their positions to Bob. Each ship looks as a 1?×?a rectangle (that is, it occupies a sequence of a consecutive squares of the field). The ships cannot intersect and even touch each other.
After that Bob makes a sequence of “shots”. He names cells of the field and Alice either says that the cell is empty (“miss”), or that the cell belongs to some ship (“hit”).
But here’s the problem! Alice like to cheat. May be that is why she responds to each Bob’s move with a “miss”.
Help Bob catch Alice cheating — find Bob’s first move, such that after it you can be sure that Alice cheated.
题意:
给你一个长度为n的一维的图形,往上边放长度为a的船,放k个
船与船之间不能重叠和相邻
然后按顺序给出不能占用的点,问在给出第几个点的时候就不能放k个船了
思路:
不能相邻的话,我们就把每个船的长度都加长一格,然后因为总会有个在边上
所以我们把区间长度+1,所以能放(len+1)/(a+1)个船
然后用Set统计每次插入要损失几个船就行了
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
推荐阅读
- codeforces B. Young Explorers
- codeforces C. Mere Array
- codeforces D. Omkar and Bed Wars
- codeforces C. Omkar and Waterslide
- codeforces B. Omkar and Infinity Clock
- codeforces B. Ternary Sequence
- 题库-CF|【Codeforces Round 370 (Div 2) E】【线段树 等比数列 区间合并】Memory and Casinos 赌场区间[l,r] l进r先出的概率
- 题库-CF|【Codeforces Round 263 (Div 2)C】【贪心 哈弗曼思维】Appleman and Toastman 每个非1size子树延展为2子树的最大权
- Codeforces|Codeforces Round #605 (Div. 3) D. Remove One Element
- Codeforces|Codeforces Round #643 (Div. 2) B.Young Explorers