Submission #1231552

#TimeUsernameProblemLanguageResultExecution timeMemory
1231552countlessPoi (IOI09_poi)C++20
100 / 100
144 ms9596 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define sp <<" "<<
#define endl "\n"

void solve() {
    int n, t, p; cin >> n >> t >> p; p--;
    vector<vector<int>> solve(n);
    vector<int> score(n), task(t); 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            int solved; cin >> solved;
            if (solved) {
                solve[i].push_back(j);
                task[j]++;
            }
        }
    }

    vector<int> weight(t);
    for (int j = 0; j < t; j++) {
        weight[j] = n - task[j];
    }

    for (int i = 0; i < n; i++) {
        for (auto &j : solve[i]) {
            score[i] += weight[j];
        }
    }

    vector<int> o(n);
    iota(o.begin(), o.end(), 0);
    sort(o.begin(), o.end(), [&](int a, int b) {
        if (score[a] == score[b] and solve[a].size() == solve[b].size()) return a < b;
        if (score[a] == score[b]) return solve[a].size() > solve[b].size();
        return score[a] > score[b];
    });

    for (int i= 0; i < n; i++) {
        if (o[i] == p) {
            cout << score[p] sp i + 1 << endl;
        }
    }
}

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...