#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define int long long
using namespace std;
int n, t, p, s[2005], a[2005][2005], num[2005];
signed main(){
	cin>>n>>t>>p;
	vector <pair <int, pair <int, int> > > v;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=t; j++){
			cin>>a[i][j];
			if(a[i][j]==0){
				s[j]++;
			}
			else{
				num[i]++;
			}
		}
	}
	for(int i=1; i<=n; i++){
		int sum=0;
		for(int j=1; j<=t; j++){
			if(a[i][j]) sum+=s[j];
		}
		v.pb({sum, {num[i], i*-1}});
	}
	sort(v.begin(), v.end());
	for(int i=n-1; i>=0; i--){
		if(v[i].ss.ss*-1==p){
			cout<<v[i].ff<<" "<<n-i;
			return 0;
		}
	}
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |