Submission #522418

#TimeUsernameProblemLanguageResultExecution timeMemory
522418nurlitadfPoi (IOI09_poi)C++17
100 / 100
562 ms23680 KiB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll modexp(ll b, ll e, ll m){
    ll r = 1;
    while(e > 0){
     if((e & 1) == 1){
         r = (r * b) % m;
     }
     e >>= 1;
     b = (b * b) % m;
    }
    return r;
}
 
bool isvowel(char ch) { 
    return (ch == 'a') || (ch == 'e') ||(ch == 'i') ||(ch == 'o') ||(ch == 'u') ||(ch == 'y'); 
}

typedef struct {
    int score, cnt, id;
} result;

bool cmp(result a, result b) {
    if(a.score > b.score)
        return true;
    if(a.score < b.score)
        return false;
    if(a.cnt > b.cnt)
        return true;
    if(a.cnt < b.cnt)
        return false;
    if(a.id < b.id)
        return true;
    return false;
}
 
int main() {
    int n, t, p;
    cin >> n >> t >> p;

    p--;

    vector<vector<int> > status(n);
    vector<int> score(t, 0);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < t; j++) {
            int v;
            cin >> v;

            status[i].push_back(v);

            if(!v)
                score[j]++;
        }
    }

    vector<result> scores;
    for(int i = 0; i < n; i++) {
        int sum = 0;
        int cnt = 0;
        for(int j = 0; j < t; j++) {
            if(status[i][j]) {
                sum += score[j];
                cnt++;
            }
        }

        scores.push_back({sum, cnt, i});
    }

    sort(scores.begin(), scores.end(), cmp);

    for(int i = 0; i < scores.size(); i++) {
        if(scores[i].id == p) {
            cout << scores[i].score << " " << i + 1 << endl;
            break;
        }
    }

    return 0;
}

Compilation message (stderr)

poi.cpp: In function 'int main()':
poi.cpp:75:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<result>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |     for(int i = 0; i < scores.size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...