首页 > 试题广场 >

money

[编程题]money
White Cloud has built n stores numbered from 1 to n.
White Rabbit wants to visit these stores in the order from 1 to n.
The store numbered i has a price a[i] representing that White Rabbit can spend a[i] dollars to buy a product or sell a product to get a[i] dollars when it is in the i-th store.
The product is too heavy so that White Rabbit can only take one product at the same time.
White Rabbit wants to know the maximum profit after visiting all stores.
Also, White Rabbit wants to know the minimum number of transactions while geting the maximum profit.
Notice that White Rabbit has infinite money initially.



输入描述:
The first line contains an integer T(0<T<=5), denoting the number of test cases.
In each test case, there is one integer n(0<n<=100000) in the first line,denoting the number of stores.
For the next line, There are n integers in range [0,2147483648), denoting a[1..n].


输出描述:
For each test case, print a single line containing 2 integers, denoting the maximum profit and the minimum number of transactions.
示例1

输入

1
5
9 10 7 6 8

输出

3 4
头像 XingHe_XingHe
发表于 2021-10-02 17:28:56
链接:https://ac.nowcoder.com/acm/contest/20323/D 来源:牛客网 题目描述 白云已经建立了n家店铺,数量从1到n不等。 白兔想按从1到n的顺序参观这些商店。 编号为i的商店有一个价格a[i],表示大白兔在第i家商店可以花费a[i]美元购买产品或销售产品以获得 展开全文