File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < bits/stdc++.h>
3
+ using namespace std ;
4
+
5
+ #define int long long
6
+ #define fast ios_base::sync_with_stdio (0 ); cin.tie(0 );
7
+
8
+ signed main (){
9
+ fast;
10
+ int t; cin>>t;
11
+ while (t--){
12
+ int n; cin>>n;
13
+ vector<pair<int ,int >> power;
14
+ for (int i=0 ;i<n;i++){
15
+ int k; cin>>k;
16
+ vector<int > v (k);
17
+ int p=0 ,maxm=0 ;
18
+ for (int j=0 ;j<k;j++){
19
+ cin>>v[j];
20
+ if (v[j]-j>maxm){
21
+ maxm=v[j]-j;
22
+ }
23
+ }
24
+ power.push_back (make_pair (maxm,k));
25
+ }
26
+ sort (power.begin (),power.end ());
27
+ int l=0 ;
28
+ vector<int > final (n);
29
+ int minp=power[0 ].first ;
30
+ for (int i=0 ;i<power.size ();i++){
31
+ final [i]=power[i].first - l;
32
+ l+=power[i].second ;
33
+ if (minp<final [i]) minp=final [i];
34
+ }
35
+ cout<<minp+1 <<" \n " ;
36
+ }
37
+ return 0 ;
38
+ }
You can’t perform that action at this time.
0 commit comments