Submission #1320596

#TimeUsernameProblemLanguageResultExecution timeMemory
1320596jahinahnafPoi (IOI09_poi)C++20
100 / 100
445 ms16180 KiB
#include <bits/stdc++.h>

#define ll long long int
#define ld long double
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sortBySecondElement [](auto &left, auto &right) { return left.second < right.second; }
#define F first
#define S second
#define fast_io                  \
	ios::sync_with_stdio(false); \
	cin.tie(nullptr);
using namespace std;

const int INF = INT_MAX;
const ll MOD = 1e9 + 7;

// BY THE NAME OF ALMIGHTY ALLAH

void solve()
{
	int N, T, P;
	cin >> N >> T >> P;
	vector<pair<int, int>> a(T);
	int z = 0;
	for (auto &x : a)
	{
		x.first = 0;
		x.second = z;
		z++;
	} // x.first = score AND x.second = index;

	vector<tuple<int, int, int>> participants(N);
	z = 1;
	for (auto &x : participants)
	{
		get<0>(x) = z;
		z++;
		get<1>(x) = 0;
		get<2>(x) = 0;
	}

	vector<vector<int>> b(N, vector<int>(T));

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < T; j++)
		{
			cin >> b[i][j];
			if (b[i][j] == 0)
			{
				a[j].first++;
			}
			else
			{
				get<1>(participants[i])++;
			}
		}
	}
	for (int i = 0; i < N; i++)
	{
		int score = 0;
		for (int j = 0; j < T; j++)
		{
			if (b[i][j] == 1)
			{
				score += a[j].first;
			}
		}
		get<2>(participants[i]) = score;
	}
	sort(all(participants), [](const auto &a, const auto &b)
		 {
			 if (get<2>(a) != get<2>(b))
				 return get<2>(a) > get<2>(b);

			 if (get<1>(a) != get<1>(b))
				 return get<1>(a) > get<1>(b);

			 return get<0>(a) < get<0>(b); });

	int pScore, pRank, c = 1;
	for (auto &x : participants){
		if (get<0>(x) == P){
			pScore = get<2>(x);
			pRank = c;
			break;
		}
		c++;
	}
	cout << pScore << ' ' << pRank;
}

int main()
{
	// freopen("aaa.in", "r", stdin);
	// freopen("aaa.out", "w", stdout);
	int t = 1, cases = 1;
	// cin >> t;
	while (t--)
	{
		// cout << "Case " << cases << ": ";
		solve();
		// cases++;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...