#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair const int inf=1e9+7; const ll mod=1e9+7; int main() { int N; cin>>N; vector > >arr(N); int tmp; for(int i=0;i>tmp; tmp--; arr[tmp].push_back(make_pair(i, j)); } } int up[N][N+1]; int down[N][N+1]; int imosu[N][N]; for(int i=0;i=N){ down[i][N]++; } else{ down[i][arr[i][j].fi+arr[i][j].se+1]++; } if(arr[i][j].fi-arr[i][j].se<0){ up[i][0]++; } else{ up[i][arr[i][j].fi-arr[i][j].se]++; imosu[i][0] += arr[i][j].fi-arr[i][j].se; } } } for(int i=0;iimosu[i][j])maximo = imosu[i][j]; } //cout<