求调
查看原帖
求调
1356942
Cstong_y楼主2024/7/22 16:45
#include <bits/stdc++.h>
using namespace std;

const int N = 100010;
int a[N], g[N], x, l, count;;


int main() {
	while (cin >> x) {
		a[++l] = x;
	}
	for (int i = 1; i <= l; i++) {
		int k = 1;
		while (k <= count && g[k] >= a[i]) {
			k++;
		}
		if (k > count) {
			g[++count] = a[i];
		} else {
			g[k] = a[i];
		}
	}
	cout << count << endl;
	count = 0;
	for (int i = 1; i <= l; i++) {
		int k = 1;
		for (; k <= count && g[k] < a[i];) {
			k++;
		}
		if (k > count) {
			g[++count] = a[i];
		} else {
			g[k] = a[i];
		}
	}
	cout << count << endl;
}
2024/7/22 16:45
加载中...