제출 #754141

#제출 시각아이디문제언어결과실행 시간메모리
754141vjudge1Poi (IOI09_poi)C++17
0 / 100
225 ms15984 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 == a.se.se) {
		if(a.se.fi == a.se.fi) return a.fi < b.fi;
		else return a.se.fi > b.se.fi;
	}
	else return a.se.se > b.se.se;
}

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; 
		}
	}
}

컴파일 시 표준 에러 (stderr) 메시지

poi.cpp: In function 'bool comparator(std::pair<int, std::pair<int, int> >&, std::pair<int, std::pair<int, int> >&)':
poi.cpp:9:13: warning: self-comparison always evaluates to true [-Wtautological-compare]
    9 |  if(a.se.se == a.se.se) {
      |             ^~
poi.cpp:10:14: warning: self-comparison always evaluates to true [-Wtautological-compare]
   10 |   if(a.se.fi == a.se.fi) return a.fi < b.fi;
      |              ^~
#Verdict Execution timeMemoryGrader output
Fetching results...