RE 80 求助???
查看原帖
RE 80 求助???
80298
NetherDevil楼主2020/11/9 23:03

RT ,就这段代码,最后两个点 RE

#include <iostream>
using namespace std;
int nData[1000000];
int nSTList[100][1000000];
inline int fnGetMaximumPower(int n) {
	int nResult;
	for (nResult = 0;n >= (1 << nResult);nResult++);
	return nResult - 1;
}
inline int fnMaximum(int x,int y) {
	return x < y ? y : x;
}
int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0;i < n;i++) {
		cin >> nData[i];
		nSTList[0][i] = nData[i];
	}
	for (register int i = 1, e1 = fnGetMaximumPower(n);i <= e1;i++) {
		for (register int j = 0;j <= (n - (1 << i));j++) {
			nSTList[i][j] = fnMaximum(nSTList[i - 1][j], nSTList[i - 1][j + (1 << (i - 1))]);
		}
	}
	for (int i = 0;i < m;i++) {
		int nStart, nEnd;
		cin >> nStart >> nEnd;
		nStart--;
		nEnd--;
		if (nEnd < nStart) {
			int temp = nEnd;
			nEnd= nStart;
			nStart = temp;
		}
		cout << fnMaximum(nSTList[fnGetMaximumPower(nEnd - nStart)][nStart], nSTList[fnGetMaximumPower(nEnd - nStart)][nEnd - (1 << fnGetMaximumPower(nEnd - nStart)) + 1]) << endl;

	}
	return 0;
}
2020/11/9 23:03
加载中...