2018牛客暑期ACM多校训练营第二场 - D题

D. 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 In each test case, there is one integer n(0 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

#include
#include
using namespace std;
typedef long long int ll;
ll dp[100010][0];
ll map1[100010];
int n;
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		scanf("%lld",&map1[1]);
		ll temp0=0,temp1=-map1[1],cont0=0,cont1=1;
		dp[1][0]=0;
		dp[1][1]=-map1[1];
		for(int i=2;i<=n;++i)
		{
			scanf("%lld",&map1[i]);
			if(temp0temp1)
			printf("%lld %lld\n",temp0,cont0);
		else if(temp0

 

你可能感兴趣的:(ACM,牛客多校训练)