Submission #752815

#TimeUsernameProblemLanguageResultExecution timeMemory
752815vjudge1Poi (IOI09_poi)C++17
100 / 100
584 ms39676 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> tpl;
const ll MAXN = 2e3 + 5;

ll n, t, p, arr[MAXN][MAXN], poinSoal[MAXN];
tpl standing[MAXN];
// {{Score, Jumlah}, Id}

bool cmp(tpl a, tpl b){
	if (a == b)
	{
		return false;
	}

	if (a.first.first == b.first.first)
	{
		if (a.first.second == b.first.second)
		{
			return a.second < b.second;
		}
		return a.first.second > b.first.second;
	}

	return a.first.first > b.first.first;
}

int main(){
	cin >> n >> t >> p;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= t; ++j)
		{
			cin >> arr[i][j];
			if (arr[i][j] == 0)
			{
				poinSoal[j]++;
			}
		}
	}

	for (int i = 1; i <= n; ++i)
	{
		standing[i].second = i;
		for (int j = 1; j <= t; ++j)
		{
			if (arr[i][j] == 1)
			{
				standing[i].first.first += poinSoal[j];
				standing[i].first.second++;
			}
		}
	}

	sort(standing+1, standing+1+n, cmp);

	for (int i = 1; i <= n; ++i)
	{
		if (standing[i].second == p)
		{
			cout << standing[i].first.first << " " << i << "\n";
		}
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...