代码如下,请问为什么最低分会算错?
查看原帖
代码如下,请问为什么最低分会算错?
657638
6vz5ukvd楼主2022/1/1 02:43

#2 #3 WA: Wrong Answer.wrong answer On line 1 column 2, read 0, expected 8.

我想应该是最低分算错了,但是我找了半天也没有弄清楚原因。

代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>

inline bool sortComparePSSR1N2(const std::pair<short, short> &a, const std::pair<short, short> &b) {
	return (a.first != b.first) ? (a.first > b.first) : (a.second < b.second);
}

std::pair<short, short> vulInfo[5001];

int main() {
	short n, m;
	scanf("%hd %hd", &n, &m);
	for (register short i = 0; i < n; ++ i) {
		scanf("%hd %hd", &vulInfo[i].second, &vulInfo[i].first);
	}
	std::sort(vulInfo, vulInfo + n, sortComparePSSR1N2);
	vulInfo[n].first = -1;
	{
		register short minScore = vulInfo[(long) (m * 1.5)].first, nPCnt;
		for (nPCnt = m * 1.5; vulInfo[nPCnt].first >= minScore; ++ nPCnt);
		printf("%hd %hd\n", minScore, nPCnt);
		for (register short i = 0; i < nPCnt; ++ i) {
			printf("%hd %hd\n", vulInfo[i].second, vulInfo[i].first);
		}
	}
	printf("\n");
	return 0;
}
2022/1/1 02:43
加载中...