10分求调!!!

P1091 [NOIP2004 提高组] 合唱队形

@[ZBXALQX](/user/1070547) > 合唱队形是指这样的一种队形:设 $k$ 位同学从左到右依次编号为 $1,2,$ … $,k$,他们的身高分别为 $t_1,t_2,$ … $,t_k$,则他们的身高满足 $t_1< \cdots <t_i>t_{i+1}>$ … $>t_k(1\le i\le k)$。 你除了正向跑 LIS,还要反向跑一遍,再统计最大值。
by __PRO__ @ 2024-01-29 09:32:14


@[__PRO__](/user/534597) 也就是说。。。。。要怎么写代码
by ZBXALQX @ 2024-01-29 09:42:03


@[ZBXALQX](/user/1070547) 我改了下码风: ```cpp #include <bits/stdc++.h> using namespace std; int n, a[5005], f[5005], g[5005], sum; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { f[i] = 1; for (int j = 1; j < i; j++) { if (a[j] < a[i]) { f[i] = max(f[i], f[j] + 1); } } } for (int i = n; i >= 1; i--) { g[i] = 1; for (int j = n; j > i; j--) { if (a[j] < a[i]) { g[i] = max(g[i], g[j] + 1); } } } for (int i = 1; i <= n; ++i) { sum = max(sum, f[i] + g[i] - 1); } cout << n - sum << endl; return 0; } ```
by __PRO__ @ 2024-01-29 09:46:53


@[__PRO__](/user/534597) 这份20分
by ZBXALQX @ 2024-01-29 09:54:47


@[__PRO__](/user/534597) [20分](https://www.luogu.com.cn/record/144924212)
by ZBXALQX @ 2024-01-29 09:55:57


@[ZBXALQX](/user/1070547) [100 pts](https://www.luogu.com.cn/record/144925184)
by __PRO__ @ 2024-01-29 09:58:59


@[__PRO__](/user/534597) 代码是你上面那个吗?
by ZBXALQX @ 2024-01-29 10:00:37


@[ZBXALQX](/user/1070547) 你是不是交错代码了,我这边比对了一下,一样的代码,我这边 100 分。
by __PRO__ @ 2024-01-29 10:01:07


@[ZBXALQX](/user/1070547) 我又交了一遍,直接复制的代码,还是 100 分。
by __PRO__ @ 2024-01-29 10:02:06


@[__PRO__](/user/534597) 谢谢dalao
by ZBXALQX @ 2024-01-29 10:07:13


|