CF1832C.Contrast Value
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For an array of integers [a1,a2,…,an] , let's call the value ∣a1−a2∣+∣a2−a3∣+⋯+∣an−1−an∣ the contrast of the array. Note that the contrast of an array of size 1 is equal to 0 .
You are given an array of integers a . Your task is to build an array of b in such a way that all the following conditions are met:
- b is not empty, i.e there is at least one element;
- b is a subsequence of a , i.e b can be produced by deleting some elements from a (maybe zero);
- the contrast of b is equal to the contrast of a .
What is the minimum possible size of the array b ?
输入格式
The first line contains a single integer t ( 1≤t≤104 ) — the number of test cases.
The first line of each test case contains a single integer n ( 1≤n≤3⋅105 ) — the size of the array a .
The second line contains n integers a1,a2,⋅,an ( 0≤ai≤109 ) — elements of the array itself.
The sum of n over all test cases doesn't exceed 3⋅105 .
输出格式
For each test case, print a single integer — the minimum possible size of the array b .
输入输出样例
输入#1
4 5 1 3 3 3 7 2 4 2 4 1 1 1 1 7 5 4 2 1 0 0 4
输出#1
2 2 1 3