Submission #399388

#TimeUsernameProblemLanguageResultExecution timeMemory
399388iulia13Poi (IOI09_poi)C++14
100 / 100
708 ms16140 KiB
#include <iostream>
#include <algorithm>

using namespace std;
const int nmax = 2005;
int a[nmax][nmax];
int v[nmax];
struct ura{
    int sc, id, tsk;
};
ura b[nmax];
bool cmp(ura x, ura y)
{
    if (x.sc != y.sc)
        return x.sc > y.sc;
    if (x.tsk != y.tsk)
        return x.tsk > y.tsk;
    return x.id < y.id;
}
int main()
{
    int n, t, p, i, j;
    cin >> n >> t >> p;
    for (i = 1; i <= n; i++)
        for (j = 1; j <= t; j++)
            cin >> a[i][j], b[i].tsk += a[i][j];
    for (j = 1; j <= t; j++)
        for (i = 1; i <= n; i++)
            v[j] += (1 - a[i][j]);
    for (i = 1; i <= n; i++)
    {
        b[i].id = i;
        for (j = 1; j <= t; j++)
            b[i].sc += a[i][j] * v[j];
    }
    sort (b + 1, b + n + 1, cmp);
    for (i = 1; i <= n; i++)
        if (b[i].id == p)
        {
            cout << b[i].sc << " " << i;
            return 0;
        }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...