#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<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];
}
}
vector<int> c(m);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; 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 + 1;
}
sort(score.begin(), score.end(), [&](pair<int, int> x, pair<int, int> y) {
if (x.first == y.first) {
return x.second < y.second;
}
return x.first > y.first;
});
for (int i = 0; i < n; i++) {
if (score[i].second == p) {
cout << score[i].first << ' ' << score[i].second << '\n';
return 0;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |