jdyyds

guanyuxun 2021-07-25 11:52:06 5

#include using namespace std; int f[111], d[111], a[111]; int main() { int k; cin >> k; while (k--) { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { f[i] = d[i] = 1; for (int j = 1; j < i; j++) { if (a[j] < a[i]) { f[i] = max(f[i], f[j] + 1); } else if (a[j] > a[i]) { d[i] = max(d[i], d[j] + 1); } } } int res = 0; for (int i = 1; i <= n; i++) { res = max(res, max(d[i], f[i])); } cout << res << endl; }

return 0;

}

{{ vote && vote.total.up }}

共 2 条回复

bc02

、没有换行

bcm18

!?