Submission #754140

#TimeUsernameProblemLanguageResultExecution timeMemory
754140vjudge1Poi (IOI09_poi)C++17
85 / 100
273 ms15960 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;
	if(a.se.fi != b.se.se) return a.se.fi > b.se.fi;
	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;
	p-=1;

	// input & data nilai 0 (nilai tambah)
	int nilai[n][t], skortempo[t];
	memset(skortempo, 0, sizeof(skortempo));
	for(int i=0; i<n; i++) {
		for(int j=0; j<t; j++) {
			cin >> nilai[i][j];
			if(nilai[i][j] == 0) skortempo[j]++;
		}
	}

	pair <int, pair <int, int>> data[n]; // id, (solved task count, nilai total)
	for(int i=0; i<n; i++) {
		data[i].fi = i;
		data[i].se.fi = 0;
		data[i].se.se = 0;
		for(int j=0; j<t; j++) {
			if(nilai[i][j] != 0) {
				data[i].se.se += skortempo[j];
				data[i].se.fi++;
			}
		}
	}

	sort(data, data+n, comparator);

	for(int i=0; i<n; i++) {
		if(data[i].fi == p) {
			cout << data[i].se.se << " " << i+1;
			break; 
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...