제출 #890678

#제출 시각아이디문제언어결과실행 시간메모리
890678HasanV11010238Poi (IOI09_poi)C++17
100 / 100
471 ms24460 KiB
#include <bits/stdc++.h>
using namespace std;
bool comparestudents(vector<int> v1, vector<int> v2){
    if (v1[0] < v2[0]){
        return true;
    }
    else if (v1[0] > v2[0]){
        return false;
    }
    if (v1[1] < v2[1]){
        return true;
    }
    else if (v1[1] > v2[1]){
        return false;
    }
    if (v1[2] > v2[2]){
        return true;
    }
    return false;
}
int main(){
    int n, t, p, a;
    cin>>n>>t>>p;
    vector<vector<int>> v(n);
    vector<int> co(t, n);
    vector<vector<int>> stud;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < t; j++){
            cin>>a;
            if (a == 1){
                co[j] -= 1;
            }
            v[i].push_back(a);
        }
    }
    for (int i = 0; i < n; i++){
        int coun = 0, points = 0; 
        for (int j = 0; j < t; j++){
            points += v[i][j] * co[j];
            coun += v[i][j];
        }
        stud.push_back({points, coun, i + 1});
    }
    sort(stud.begin(), stud.end(), comparestudents);
    reverse(stud.begin(), stud.end());
    for (int i = 0; i < n; i++){
        if (stud[i][2] == p){
            cout<<stud[i][0]<<" "<<i + 1;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...