#include <bits/stdc++.h>
using namespace std;
int main() {
int n, t, p;
cin >> n >> t >> p;
p--;
vector<vector<int>> vvi(n, vector<int>(t));
for (auto &a : vvi) {
for (auto &b : a)
cin >> b;
}
vector<int> worth(t);
for (int j = 0; j < t; j++) {
for (int i = 0; i < n; i++) {
if (vvi[i][j] == 0)
worth[j]++;
}
}
vector<vector<int>> ans;
for (int i = 0; i < n; i++) {
int sum = 0, ct = 0;
for (int j = 0; j < t; j++) {
if (vvi[i][j]) {
sum += worth[j];
ct++;
}
}
ans.push_back({sum, ct, i});
}
sort(ans.begin(), ans.end(), [&](vector<int> a, vector<int> b) {
if (a[0] != b[0])
return a[0] > b[0];
if (a[1] != b[1])
return a[1] > b[1];
return a[2] < b[2];
});
for (int i = 0; i < n; i++) {
if (ans[i][2] == p) {
cout << ans[i][0] << " " << i + 1 << "\n";
return 0;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |