CF1616C.Representative Edges
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
An array a1,a2,…,an is good if and only if for every subsegment 1≤l≤r≤n, the following holds: al+al+1+…+ar=21(al+ar)⋅(r−l+1).
You are given an array of integers a1,a2,…,an. In one operation, you can replace any one element of this array with any real number. Find the minimum number of operations you need to make this array good.
数组 a1,a2,…,an 是“好”的,当且仅当对每个子段 1≤l≤r≤n,均满足:
al+al+1+…+ar=21(al+ar)⋅(r−l+1).
给定一个整数数组 a1,a2,…,an。每次操作中,你可以将该数组中的任意一个元素替换为任意实数。求使该数组变为“好”数组所需的最少操作次数。
输入格式
The first line of input contains one integer t (1≤t≤100): the number of test cases.
Each of the next t lines contains the description of a test case.
In the first line you are given one integer n (1≤n≤70): the number of integers in the array.
The second line contains n integers a1,a2,…,an (−100≤ai≤100): the initial array.
输入的第一行包含一个整数 t(1≤t≤100):测试用例的数量。
接下来的 t 行,每行描述一个测试用例。
在每个测试用例的第一行中,给出一个整数 n(1≤n≤70):数组中整数的个数。
第二行包含 n 个整数 a1,a2,…,an(−100≤ai≤100):初始数组。
输出格式
For each test case, print one integer: the minimum number of elements that you need to replace to make the given array good.
对于每个测试用例,输出一个整数:使给定数组变为“好”数组所需替换的最少元素个数。
输入输出样例
输入#1
5 4 1 2 3 4 4 1 1 2 2 2 0 -1 6 3 -2 4 -1 -4 0 1 -100
输出#1
0 2 0 3 0
说明/提示
In the first test case, the array is good already.
In the second test case, one of the possible good arrays is [1,1,1,1] (replaced elements are underlined).
In the third test case, the array is good already.
In the fourth test case, one of the possible good arrays is [−2.5,−2,−1.5,−1,−0.5,0].
在第一个测试用例中,该数组已经是好数组。
在第二个测试用例中,一个可能的好数组是 [1,1,1,1](被替换的元素用下划线标出)。
在第三个测试用例中,该数组已经是好数组。
在第四个测试用例中,一个可能的好数组是 [−2.5,−2,−1.5,−1,−0.5,0]。
输入解题思路,AI测评打分。不知道怎么写?