Skip to content

Commit 0792031

Browse files
authored
Merge pull request kothariji#567 from Source-404/source404
Added codeforces Deep_down_below.cpp
2 parents f466a82 + e869d50 commit 0792031

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)