Submission #536060

# Submission time Handle Problem Language Result Execution time Memory
536060 2022-03-12T08:44:21 Z Spartan117 Poi (IOI09_poi) C++14
15 / 100
289 ms 39664 KB
#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
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Incorrect 1 ms 316 KB Output isn't correct
4 Correct 1 ms 320 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Runtime error 1 ms 468 KB Execution killed with signal 6
7 Incorrect 1 ms 328 KB Output isn't correct
8 Runtime error 1 ms 596 KB Execution killed with signal 6
9 Incorrect 2 ms 340 KB Output isn't correct
10 Runtime error 3 ms 852 KB Execution killed with signal 6
11 Incorrect 9 ms 1108 KB Output isn't correct
12 Runtime error 15 ms 2900 KB Execution killed with signal 6
13 Incorrect 41 ms 4252 KB Output isn't correct
14 Runtime error 69 ms 10308 KB Execution killed with signal 6
15 Incorrect 121 ms 12860 KB Output isn't correct
16 Runtime error 150 ms 24872 KB Execution killed with signal 6
17 Incorrect 175 ms 17104 KB Output isn't correct
18 Runtime error 192 ms 33480 KB Execution killed with signal 6
19 Runtime error 265 ms 39664 KB Execution killed with signal 6
20 Correct 289 ms 23164 KB Output is correct