Submission #753751

#TimeUsernameProblemLanguageResultExecution timeMemory
753751vjudge1Poi (IOI09_poi)C++17
0 / 100
200 ms8116 KiB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;

bool comparator(pair<int, pair<int, int>>& a, pair<int, pair<int, int>>& b) {
    if(a.se.se != b.se.se) return a.se.se > b.se.se;
    else return a.fi < b.fi;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n, t, p;
    cin >> n >> t >> p;
    vector <pair<int, pair<int, int>>> data(t); // id (skor, sum)

    for(auto element : data) {
        element.se.se = 0;
    }

    for(int i=0; i<t; i++) {
        data[i].fi = i;
    }

    for(int i=0; i<n; i++) {
        for(int j=0; j<t; j++) {
            cin >> data[j].se.fi;
            data[j].se.se += data[j].se.fi;
        }
    }

    sort(data.begin(), data.end(), comparator);

    int rank, score;
    for(int i=0; i<t; i++) {
        if(data[i].fi+1 == p) {
            score = data[i].se.se; 
            rank = i+1;
            break;
        }
    }
    cout << score << " " << rank;
}

Compilation message (stderr)

poi.cpp: In function 'int main()':
poi.cpp:21:14: warning: variable 'element' set but not used [-Wunused-but-set-variable]
   21 |     for(auto element : data) {
      |              ^~~~~~~
poi.cpp:46:22: warning: 'score' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |     cout << score << " " << rank;
      |                      ^~~
poi.cpp:46:29: warning: 'rank' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |     cout << score << " " << rank;
      |                             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...