제출 #1266813

#제출 시각아이디문제언어결과실행 시간메모리
1266813haithamcoderPoi (IOI09_poi)C++20
100 / 100
139 ms17644 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const int MOD = 1000000007;
const ll LOG = 31;

#define db(x) cerr << #x << " = " << x << " | "
#define dbg(x) cerr << #x << " = " << x << "\n"

#define Algerian ios::sync_with_stdio(0);
#define OI cin.tie(NULL);

#define f first
#define s second

int main() {
    Algerian OI

    ll n, t, p;
    cin >> n >> t >> p;

    vector<vector<ll>> contestant(n);

    vector<ll> tasks(t, n);
    
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < t; j++) {
            ll c;
            cin >> c;

            if (c) {
                contestant[i].push_back(j);
                tasks[j]--;
            }
        }
    }

    vector<pair<pll, ll>> scores(n);

    for (ll i = 0; i < n; i++) {
        ll cur = 0;

        for (auto x : contestant[i]) cur += tasks[x];
        scores[i] = {{cur, contestant[i].size()}, i};
    }
    --p;

    auto cmp = [=](pair<pll, ll> a, pair<pll, ll> b) -> bool {
        if (a.f.f != b.f.f) return a.f.f > b.f.f;
        else if (a.f.s != b.f.s) return a.f.s > b.f.s;
        else return a.s < b.s;
    };

    sort(scores.begin(), scores.end(), cmp);

    ll idx, score;

    for (ll i = 0; i < n; i++) {
        if (scores[i].s == p) {
            idx = i;
            score = scores[i].f.f;
        }
    }

    cout << score << " " << idx + 1 << "\n";

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...