| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 536060 | Spartan117 | Poi (IOI09_poi) | C++14 | 289 ms | 39664 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct contestant
{
    int id;
    int score;
    int numOfTasksSolved;
    contestant()
    {
        id = 0;
        score = 0; 
        numOfTasksSolved = 0;
    }
};
bool compareContestants (contestant &contestant1, contestant &contestant2)
{
    if (contestant1.score > contestant2.score)
        return true;
    else if (contestant1.score == contestant2.score)
    {
        if (contestant1.numOfTasksSolved > contestant2.numOfTasksSolved)
            return true;
        else if (contestant1.numOfTasksSolved == contestant2.numOfTasksSolved)
            return contestant1.id < contestant2.id;
        else 
            return false;
    }
    else
        return false;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n{}, t{}, p{};
    cin >> n >> t >> p;
    
    vector<vector<int>> contestant_solvedTask (n);  //reading input
    for (int i{}; i<n; i++)
    {
        for (int j{}; j<t; j++)
        {
            int taskSolved{};
            cin >> taskSolved;
            contestant_solvedTask[i].push_back(taskSolved);
        }
    }
    
    vector<int> taskScores (t);
    
    for (int i{}; i<n; i++) //calculating points for each task
    {
        for (int j{}; j<n; j++)
        {
            if (contestant_solvedTask[i][j]==0)
                taskScores[j]++;
        }
    }
    
    
    
    vector<contestant> contestants (n) ;    //finding scores and numOfTasksSolved by each student
    for (int i{}; i<n; i++)
    {
        contestants[i].id = i;
        for (int j{}; j<n; j++)
        {
            if (contestant_solvedTask[i][j]==1)
            {
                contestants[i].score += taskScores[j];
                contestants[i].numOfTasksSolved++;
            }
        }
    }
    
    sort(contestants.begin(), contestants.end(), compareContestants);   //ranking them (sorting)
    
    int philipScore {}, philipRank {};
    for (int i{}; i<n; i++) //finding philip's score and rank
    {
        if (contestants[i].id==p-1)
        {
            philipScore = contestants[i].score;
            philipRank = i+1;
            break;
        }
    }
    
    cout << philipScore << ' ' <<philipRank << '\n';
    
    
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
