Submission #634759

#TimeUsernameProblemLanguageResultExecution timeMemory
634759PolishFighterPoi (IOI09_poi)C++17
80 / 100
201 ms9648 KiB
#include<bits/stdc++.h>

using namespace std;

constexpr int MAXN = 2e3 + 10;

int score[MAXN];
int task[MAXN];
vector<int> cont[MAXN];

bool check(int a, int b)
{
	if(score[a] > score[b])
		return true;

	if(score[a] == score[b])
	{
		if(cont[a].size() >= cont[b].size())
			return cont[a].size() > cont[b].size();
		return a < b;
	}
		
	return false;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	int n, t, p, tmp;
	cin >> n >> t >> p;

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < t; j++)
		{
			cin >> tmp;
			if(tmp == 0)
				task[j]++;
			else
				cont[i].push_back(j);
		}
	}
	vector<int> cont_s;

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < cont[i].size(); j++)
		{
			score[i] += task[cont[i][j]];
		}
		cont_s.push_back(i);
	}
	p--;
	sort(cont_s.begin(), cont_s.end(), check);

	for(int i = 0; i < n; i++)
	{
		if(cont_s[i] == p)
		{
			cout << score[cont_s[i]] << " " << i+1 << "\n";
			return 0;
		}
	}

	return 0;
}

Compilation message (stderr)

poi.cpp: In function 'int main()':
poi.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for(int j = 0; j < cont[i].size(); j++)
      |                  ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...