# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
924796 | boris_mihov | Poi (IOI09_poi) | C++17 | 176 ms | 24152 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
typedef long long llong;
const int MAXN = 2000 + 10;
const int INF = 1e9;
int n, m, p;
int sum[MAXN];
int score[MAXN];
int cntTasks[MAXN];
int a[MAXN][MAXN];
int order[MAXN];
void solve()
{
for (int i = 1 ; i <= n ; ++i)
{
for (int j = 1 ; j <= m ; ++j)
{
sum[j] += !a[i][j];
}
}
for (int i = 1 ; i <= n ; ++i)
{
for (int j = 1 ; j <= m ; ++j)
{
score[i] += (a[i][j] == 1) * sum[j];
cntTasks[i] += (a[i][j] == 1);
}
}
std::iota(order + 1, order + 1 + n, 1);
std::sort(order + 1, order + 1 + n, [&](int x, int y)
{
return score[x] > score[y] || (score[x] == score[y] && cntTasks[x] > cntTasks[y]) || (score[x] == score[y] && cntTasks[x] == cntTasks[y] && x < y);
});
for (int i = 1 ; i <= n ; ++i)
{
if (order[i] == p)
{
std::cout << score[p] << ' ' << i << '\n';
return;
}
}
assert(false);
}
void input()
{
std::cin >> n >> m >> p;
for (int i = 1 ; i <= n ; ++i)
{
for (int j = 1 ; j <= m ; ++j)
{
std::cin >> a[i][j];
}
}
}
void fastIOI()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIOI();
input();
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |