Y - Strange Partition

Y - Strange Partition
You are given an array a of length n, and an integer x. You can perform the following operation as many times as you would like (possibly zero): replace two adjacent elements of the array by their sum. For example, if the initial array was [3,6,9], in a single operation one can replace the last two elements by their sum, yielding an array [3,15], or replace the first two elements to get an array [9,9]. Note that the size of the array decreases after each operation.

The beauty of an array b=[b1,…,bk] is defined as ∑ki=1⌈bix⌉, which means that we divide each element by x, round it up to the nearest integer, and sum up the resulting values. For example, if x=3, and the array is [4,11,6], the beauty of the array is equal to ⌈43⌉+⌈113⌉+⌈63⌉=2+4+2=8.

Please determine the minimum and the maximum beauty you can get by performing some operations on the original array.

Input
The first input line contains a single integer t — the number of test cases (1≤t≤1000).

The first line of each test case contains two integers n and x (1≤n≤105, 1≤x≤109).

The next line contains n integers a1,a2,…,an (1≤ai≤109), the elements of the array a.

It is guaranteed that the sum of values of n over all test cases does not exceed 105.

Output
For each test case output two integers — the minimal and the maximal possible beauty.

Example
Input

2
3 3
3 6 9
3 3
6 4 11
Output
6 6
7 8
Note
In the first test case the beauty of the array does not change if we perform any operations.

In the second example we can leave the array unchanged to attain the maximum beauty, and to get the minimum beauty one can replace two elements 4 and 11 with their sum, yielding an array [6,15], which has its beauty equal to 7.

#include<stdio.h>
int main()
{  long long int t,n,x,a[222222],i;
   scanf("%lld",&t);
   while(t--)
   {
   long long int sum=0,max=0,min=0;
    scanf("%lld%lld",&n,&x);
       for(i=1;i<=n;i++)
       scanf("%lld",&a[i]);
       for(i=1;i<=n;i++)
       {
        sum+=a[i];
       if(sum%x==0)
        min=sum/x;
       else
        min=sum/x+1;
       }
       for(i=1;i<=n;i++)
        {
            if(a[i]%x==0)
                a[i]=a[i]/x;
            else
                a[i]=a[i]/x+1;
            max+=a[i];
        }
        printf("%lld %lld\n",min,max);
   }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值