Submission #564810

# Submission time Handle Problem Language Result Execution time Memory
564810 2022-05-19T16:38:51 Z Piokemon Poi (IOI09_poi) C++17
100 / 100
224 ms 16724 KB
#include <bits/stdc++.h>
using namespace std;

int worth[2090];
int contestants[2090][2090];
pair<pair<int,int>,int> scores[2090];

bool comp(pair<pair<int,int>,int> a, pair<pair<int,int>,int> b){
    if (a.first.first > b.first.first){
        return 1;
    }
    else if (a.first.first < b.first.first){
        return 0;
    }
    if (a.first.second > b.first.second){
        return 1;
    }
    else if(a.first.second < b.first.second){
        return 0;
    }
    if (a.second < b.second){
        return 1;
    }
    else{
        return 0;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,t,p;
    cin >> n >> t >> p;
    for (int x=0;x<=t;x++){
        worth[x] = n;
    }
    for (int x=0;x<n;x++){
        for (int y=0;y<t;y++){
            cin >> contestants[x][y];
            if (contestants[x][y] == 1){
                worth[y] -= 1;
            }
        }
    }
    for (int x=0;x<n;x++){
        scores[x].first.first = 0;
        scores[x].first.second = 0;
        scores[x].second = x+1;
        for (int y=0;y<t;y++){
            if (contestants[x][y] == 1){
                scores[x].first.first += worth[y];
                scores[x].first.second += 1;
            }
        }
    }
    sort(scores,scores+n,comp);
    for (int x=0;x<n;x++){
        if (scores[x].second == p){
            cout << scores[x].first.first << ' ' << x+1 << "\n";
            return 0;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 2 ms 1236 KB Output is correct
11 Correct 7 ms 2004 KB Output is correct
12 Correct 12 ms 3028 KB Output is correct
13 Correct 34 ms 5420 KB Output is correct
14 Correct 48 ms 7636 KB Output is correct
15 Correct 85 ms 10120 KB Output is correct
16 Correct 90 ms 10896 KB Output is correct
17 Correct 134 ms 12492 KB Output is correct
18 Correct 155 ms 14228 KB Output is correct
19 Correct 197 ms 16664 KB Output is correct
20 Correct 224 ms 16724 KB Output is correct