CF1893C.Freedom of Choice
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's define the anti-beauty of a multiset {b1,b2,…,blen} as the number of occurrences of the number len in the multiset.
You are given m multisets, where the i -th multiset contains ni distinct elements, specifically: ci,1 copies of the number ai,1 , ci,2 copies of the number ai,2,…,ci,ni copies of the number ai,ni . It is guaranteed that ai,1<ai,2<…<ai,ni . You are also given numbers l1,l2,…,lm and r1,r2,…,rm such that 1≤li≤ri≤ci,1+…+ci,ni .
Let's create a multiset X , initially empty. Then, for each i from 1 to m , you must perform the following action exactly once:
- Choose some vi such that li≤vi≤ri
- Choose any vi numbers from the i -th multiset and add them to the multiset X .
You need to choose v1,…,vm and the added numbers in such a way that the resulting multiset X has the minimum possible anti-beauty.
输入格式
Each test consists of multiple test cases. The first line contains a single integer t ( 1≤t≤104 ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer m ( 1≤m≤105 ) — the number of given multisets.
Then, for each i from 1 to m , a data block consisting of three lines is entered.
The first line of each block contains three integers ni,li,ri ( 1≤ni≤105,1≤li≤ri≤ci,1+…+ci,ni≤1017 ) — the number of distinct numbers in the i -th multiset and the limits on the number of elements to be added to X from the i -th multiset.
The second line of the block contains ni integers ai,1,…,ai,ni ( 1≤ai,1<…<ai,ni≤1017 ) — the distinct elements of the i -th multiset.
The third line of the block contains ni integers ci,1,…,ci,ni ( 1≤ci,j≤1012 ) — the number of copies of the elements in the i -th multiset.
It is guaranteed that the sum of the values of m for all test cases does not exceed 105 , and also the sum of ni for all blocks of all test cases does not exceed 105 .
输出格式
For each test case, output the minimum possible anti-beauty of the multiset X that you can achieve.
输入输出样例
输入#1
7 3 3 5 6 10 11 12 3 3 1 1 1 3 12 4 2 4 4 12 13 1 5 1 7 1000 1006 1000 1001 1002 1003 1004 1005 1006 147 145 143 143 143 143 142 1 2 48 50 48 50 25 25 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 2 1 1 1 1 1 2 1 1 1 2 1 1 2 4 8 10 11 12 13 14 3 3 3 3 2 3 4 11 12 2 2
输出#1
1 139 0 1 1 0 0
说明/提示
In the first test case, the multisets have the following form:
- {10,10,10,11,11,11,12} . From this multiset, you need to select between 5 and 6 numbers.
- {12,12,12,12} . From this multiset, you need to select between 1 and 3 numbers.
- {12,13,13,13,13,13} . From this multiset, you need to select 4 numbers.
You can select the elements {10,11,11,11,12} from the first multiset, {12} from the second multiset, and {13,13,13,13} from the third multiset. Thus, X={10,11,11,11,12,12,13,13,13,13} . The size of X is 10 , the number 10 appears exactly 1 time in X , so the anti-beauty of X is 1 . It can be shown that it is not possible to achieve an anti-beauty less than 1 .