Submission #277082

#TimeUsernameProblemLanguageResultExecution timeMemory
277082ec1117Poi (IOI09_poi)C++17
100 / 100
1125 ms9780 KiB
#include "bits/stdc++.h";
using namespace std;

#define pb push_back
#define mp make_pair

int n, t, p;
int main() {
    cin >> n >> t >> p;
    p--;
    int taskSolved[t];
    vector<int> pSolved[n];
    int pscore[n];
    for(int i=0;i<t;i++)
        taskSolved[i]=0;
    for(int i=0;i<n;i++)
        pscore[i]=0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            int x;
            cin >> x;
            if (x == 1) {
                taskSolved[j]++;
                pSolved[i].push_back(j);
            }
        }
    }
    for (int i = 0; i < t; i++) {
        taskSolved[i] = n - taskSolved[i];
    }
    vector<pair<pair<int,int>,int> >standings;
    for(int i=0;i<n;i++){
        for(int j:pSolved[i]){
            pscore[i]+=taskSolved[j];
        }
        standings.pb(mp(mp(pscore[i],pSolved[i].size()),-i));
    }
    sort(standings.begin(),standings.end());
    int rank=0, score=0;
    for(int i=n-1;i>=0;i--){
        if(standings[i].second==-p){
            rank=n-i;
            score=standings[i].first.first;
            break;
        }
    }
    cout << score << ' '<<rank;
    return 0;


}
/*
 * need to sort by custom comparator:
 * need to know score, tasks solved, id
 */

Compilation message (stderr)

poi.cpp:1:25: warning: extra tokens at end of #include directive
    1 | #include "bits/stdc++.h";
      |                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...