Submission #741771

#TimeUsernameProblemLanguageResultExecution timeMemory
741771MODDIPoi (IOI09_poi)C++14
100 / 100
611 ms15972 KiB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n, t, k;
int mat[2001][2001];
struct state{
	int points;
	int cnt_solved;
	int id;
};
bool comp(state& a, state& b){
	if(a.points == b.points){
		if(a.cnt_solved == b.cnt_solved)
			return a.id < b.id;
		else{
			return a.cnt_solved > b.cnt_solved;
		}
	}
	else
		return a.points > b.points;
}
int main(){
	cin>>n>>t>>k;
	k--;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < t; j++)
			cin>>mat[i][j];
			
	int points[t];
	memset(points, 0, sizeof points);
	for(int j = 0; j < t; j++){
		for(int i = 0; i < n; i++){
			if(mat[i][j] == 0)
				points[j]++;
		}
	}
	vector<state> arr;
	for(int i = 0; i < n; i++){
		int cnt = 0, pts = 0;
		for(int j = 0; j < t; j++){
			if(mat[i][j] == 1){
				cnt++;
				pts += points[j];
			}
			else
				continue;
		}
		state now;
		now.cnt_solved = cnt;
		now.points = pts;
		now.id = i;
		arr.pb(now);
	}
	sort(arr.begin(), arr.end(), comp);
	for(int i = 0; i < n; i++){
		if(arr[i].id == k){
			cout<<arr[i].points<<" "<<i+1<<endl;
			return 0;
		}
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...