#include<bits/stdc++.h>
using namespace std;
using tp = tuple<int, int, int>;
int n, m, p;
int main() {
scanf("%d %d %d", &n, &m, &p); p--;
vector<vector<int>> a(n, vector<int>(m));
vector<int> cnt(m, n);
for (auto &e: a) {
for (auto &E: e) scanf("%d", &E);
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) cnt[i] -= a[j][i];
}
vector<int> b(n), cnt2(n);
vector<tp> c;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) b[i] += cnt[j] * a[i][j], cnt2[i] += a[i][j];
c.emplace_back(b[i], cnt2[i], i);
}
sort(c.begin(), c.end(), [&] (const tp &p1, const tp &p2) {
auto [x1, y1, z1] = p1;
auto [x2, y2, z2] = p2;
return (x1 == x2 ? (y1 == y2 ? z1 < z2 : y1 > y2) : x1 > x2);
});
int ans = -1;
for (int i = 0; i < n; i++) {
if (get<2>(c[i]) == p) ans = i;
}
printf("%d %d", get<0>(c[ans]), ++ans);
}
Compilation message (stderr)
poi.cpp: In function 'int main()':
poi.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | scanf("%d %d %d", &n, &m, &p); p--;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
poi.cpp:13:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | for (auto &E: e) scanf("%d", &E);
| ~~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |