#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>> d(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> d[i][j];
}
}
vector<int> b(m);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
b[j] += 1 - d[i][j];
}
}
vector<array<int, 2>> a(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][0] += d[i][j] * b[j];
a[i][1] += d[i][j];
}
a[i][1] = i;
}
sort(a.begin(), a.end(), [&](array<int, 2> x, array<int, 2> y) {
if (x[0] != y[0]) return x[0] > y[0];
if (x[1] != y[1]) return x[1] > y[1];
return x[1] < y[1];
});
for (int i = 0; i < n; i++) {
if (a[i][1] == p - 1) {
cout << a[i][0] << ' ' << a[i][1] + 1 << '\n';
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |