| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 479273 | Spartan117 | Poi (IOI09_poi) | C++14 | 921 ms | 24388 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 <algorithm>
#include <vector>
#include <map>
using namespace std;
struct contestant
{
    vector<int> responses;
    int id;
    int numOfQuestions;
    int score;
    contestant(const int &i)
    {
        id = i;
        numOfQuestions = 0;
        score = 0;
    }
};
vector<contestant> contestants;
map<int, int> marksperTask;
int n{}, t{}, p{};
void inputContestants()
{
    cin >> n >> t >>p;
    int response{};
    for(int i{}; i<n; i++)
    {
        contestants.push_back(contestant(i+1));
        for(int j{}; j<t; j++)
        {
            cin >> response;
            contestants[i].responses.push_back(response);
            if(response==0)
                marksperTask[j+1]++;
        }
        int qnums{};
        for(int response: contestants[i].responses)
            qnums+=response;
        contestants[i].numOfQuestions = qnums;
    }
    
    for(int i{}; i<n; i++)
    {
        for(int j{}; j<t; j++)
            if (contestants[i].responses[j]==1)
                contestants[i].score += marksperTask[j+1];
    }
}
bool compareContestants(contestant &contestant1, contestant &contestant2)
{
    if (contestant1.score > contestant2.score)
        return true;
    else if (contestant1.score == contestant2.score)
    {
        if (contestant1.numOfQuestions > contestant2.numOfQuestions)
            return true;
        else if (contestant1.numOfQuestions == contestant2.numOfQuestions)
            return (contestant1.id < contestant2.id);
        else
            return false;
    }
    else
        return false;
}
void displayOutput()
{
    
    int pScore{}, pRank{};
    for (int i{}; i<n; i++)
        if (contestants[i].id == p)
        {
            pRank = i+1;
            pScore = contestants[i].score;
            break;
        }
    cout << pScore << ' ' << pRank << '\n';
}
int main()
{
    inputContestants();
    sort(contestants.begin(), contestants.end(), compareContestants);
    displayOutput();
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
