#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, p;
cin >> n >> m >> p;
vector<int> c(m);
vector<int> cnt(n);
vector<vector<int>> a(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
cnt[i] += a[i][j];
c[j] += 1 - a[i][j];
}
}
vector<pair<int, int>> score(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
score[i].first += a[i][j] * c[j];
}
score[i].second = i;
}
sort(score.begin(), score.end(), [&](pair<int, int> x, pair<int, int> y) {
if (x.first == y.first) {
if (cnt[x.second] == cnt[y.second]) {
return x.second < y.second;
}
return cnt[x.second] > cnt[y.second];
}
return x.first > y.first;
});
for (int i = 0; i < n; i++) {
if (score[i].second == p - 1) {
cout << score[i].first << ' ' << score[i].second << '\n';
return 0;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |