Submission #472807

#TimeUsernameProblemLanguageResultExecution timeMemory
472807dron_rpPoi (IOI09_poi)C++14
100 / 100
342 ms24196 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

struct Participant{
    int id, tasks, points;
    vector<int> scores;
};

void getScoreProblems(int n, int t, vector<int>& problems, vector<Participant>& participants){
    int x;
    for (int i = 0; i<n; i++){
        participants[i].id = i+1;
        int sum = 0;
        for (int j = 0; j<t; j++){
            cin >> x;
            if (x == 0){
                problems[j]++;
            } else {
                sum++;
            }
            participants[i].scores.push_back(x);
        }
        participants[i].tasks = sum;
        participants[i].points = 0;
    }
}

bool comp(Participant& a, Participant& b){
    if (a.points != b.points){
        return a.points >= b.points;
    }
    if (a.tasks != b.tasks){
        return a.tasks >= b.tasks;
    }
    return a.id <= b.id;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, t, p;
    cin >> n >> t >> p;
    vector<int> problems(t, 0);
    vector<Participant> participants(n);
    getScoreProblems(n, t, problems, participants);
    
    for (int i = 0; i<n; i++){
        int sum = 0;
        for (int j = 0; j<t; j++){
            if (participants[i].scores[j] != 0) sum += problems[j];
        }
        participants[i].points = sum;
    }
    sort(participants.begin(), participants.end(), comp);
    for (int i = 0; i<n; i++){
        if (participants[i].id == p){
            cout << participants[i].points << " " << i+1 << "\n";
            break;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...