#include <bits/stdc++.h>
using namespace std;
void optimize()
{
cin.tie(0) -> sync_with_stdio(0);
}
bool cmp(const pair<int, pair<int, int>>& a, const pair<int, pair<int, int>>& b )
{
if(a.second.first != b.second.first)
{
return a.second.first > b.second.first;
}
if(a.second.second != b.second.second)
{
return a.second.second > b.second.second;
}
return a.first < b.first;
}
int main()
{
optimize();
int n, t, p; cin >> n >> t >> p;
int grid[n + 1][t + 1];
vector<int> points(t + 1, 0);
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= t; ++j)
{
cin >> grid[i][j];
if(grid[i][j])
points[j]++;
}
}
vector<pair<int, pair<int, int>>> score(n + 1, {0, {0, 0}});
for(int i = 1; i <= n; ++i)
{
score[i].first = i;
for(int j = 1; j <= t; ++j)
{
if(grid[i][j])
{
score[i].second.first += n - points[j];
score[i].second.second++;
}
}
}
sort(score.begin(), score.end(), cmp);
int ans = 0, pos = 1;;
for(int i = 1; i <= n; ++i)
{
if(score[i].first == p)
{
ans = score[i].second.first;
pos = score[i].first;
break;
}
}
cout << ans << " " << pos << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |