编程介的小学生 2019-02-12 22:45 采纳率: 20.5%
浏览 286

数字分配到集合里面的问题,问有哪些分配方式,采用C语言

Problem Description
Far far away, there live a lot of dogs in the forest. Unlike other dogs, those dogs love candies much more than bones.

Every candy has two attributes: the sweetness degree p and the sourness degree q. Different dogs like different candies. A dog also has two attributes: the fondness degree for sweetness x and the fondness degree for sourness y. So the deliciousness degree of a candy for a dog is defined as p×x + q×y.

The dog king has a huge candy box. At first, the box is empty. The king can add candies to the box or take some candies from the box and eat them. There are always some dogs who want to know which candies in the box are the most delicious for them. Please help the king to answer their questions.

Input
The input consists of at most 10 test cases. For each test case, the first line contains an integer n indicating that there are n candy box operations(1 <= n <= 50000).

The following n lines describe the n operations.

Each operation contains three integers t, x and y( 0 <= |x|, |y| <= 109). The first integer t may be -1, 0, or 1.

If t equals -1, it means that a candy in the box with sweetness degree x and sourness degree y is eaten by the dog king.

If t equals 1, it means that a candy with sweetness degree x and sourness degree y is added to the candy box.

If t equals 0, it means that a dog with sweetness fondness degree x and sourness fondness degree y wants to know the maximal deliciousness degree of the candies in the box for him.

It is guaranteed that every candy is unique in the box.

The input ends by n = 0.

Output
For each operation in which t equals to 0, you should print the maximal deliciousness degree of the best candy for the dog.

Sample Input
6
1 2 1
1 1 2
1 1 1
0 2 1
-1 2 1
0 2 1
0

Sample Output
5
4

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用三极管设计一个单管共射放大电路
    • ¥20 fluent无法启动
    • ¥15 孟德尔随机化r语言运行问题
    • ¥15 pyinstaller编译的时候出现No module named 'imp'
    • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
    • ¥15 怎么把多于硬盘空间放到根目录下
    • ¥15 Matlab问题解答有两个问题
    • ¥15 LCD12864中文显示
    • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
    • ¥15 gsoap生成onvif框架