제출 #405598

#제출 시각아이디문제언어결과실행 시간메모리
405598JasiekstrzPoi (IOI09_poi)C++17
100 / 100
331 ms16580 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=2e3;
struct W
{
	int s,c,id;
	bool operator<(const W &oth)
	{
		if(s==oth.s && c==oth.c)
			return id<oth.id;
		else if(s==oth.s)
			return c>oth.c;
		return s>oth.s;
	}
};
int sc[N+10];
int tab[N+10][N+10];
W w[N+10];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,t,p;
	cin>>n>>t>>p;
	for(int i=1;i<=t;i++)
		sc[i]=n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=t;j++)
		{
			cin>>tab[i][j];
			if(tab[i][j])
				sc[j]--;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=t;j++)
		{
			w[i].s+=tab[i][j]*sc[j];
			w[i].c+=tab[i][j];
		}
		w[i].id=i;
	}
	sort(w+1,w+n+1);
	for(int i=1;i<=n;i++)
	{
		if(w[i].id==p)
		{
			cout<<w[i].s<<" "<<i<<"\n";
			break;
		}
	}
	return 0;
}

#Verdict Execution timeMemoryGrader output
Fetching results...