wa第一第二个点,不知道为啥,求助大佬们
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
int main(int argc, const char * argv[]) {
ios::sync_with_stdio(false);
int m, n; cin >> m;
while (m--) {
cin >> n; vector<int> h(n + 1), dp(n + 1, 1), cnt(n + 1, 1); dp[0] = cnt[0] = 0;
for (int i = 1; i <= n; ++i) cin >> h[i];
for (int i = 1; i <= n; ++i) {
for (int j = 1; j < i; ++j) {
if (h[i] > h[j] and dp[j] + 1 > dp[i]) {
dp[i] = dp[j] + 1;
cnt[i] = cnt[j];
} else if (h[i] > h[j] and dp[j] + 1 == dp[i]) {
cnt[i] += cnt[j];
}
}
}
int t = 0, x = cnt[1];
for (int i = 1; i <= n; ++i) if (dp[i] > t) {t = dp[i]; x = cnt[i];}
cout << t << " " << x << endl;
}
return 0;
}