x 的初期數字要和1 take max. 因爲tree[0] = 0嘛
by lckcode @ 2018-07-23 21:37:59
@[SkyXH](/space/show?uid=73224) ``额……没听懂``
by Xxzxx @ 2018-07-23 21:39:18
@[_WA自动机_](/space/show?uid=82363) lz我给你一个pascal程序行不?
~~我 不 会 C + +~~
by willbe233 @ 2018-07-23 21:41:59
@[i_happy1Rock](/space/show?uid=96544) hehe
~~我不会``pasca``~~
by Xxzxx @ 2018-07-23 21:49:32
@[_WA自动机_](/space/show?uid=82363) 建议换头像
by applese @ 2018-07-23 21:52:54
@[_WA自动机_](/space/show?uid=82363) 嗯……这就很尴尬了。。。
by willbe233 @ 2018-07-23 21:53:24
@[i_happy1Rock](/space/show?uid=96544) 呵呵呵
by Xxzxx @ 2018-07-23 21:55:11
@[蒟蒻求轻D](/space/show?uid=46105) ```不换不换就不换啦啦啦```
by Xxzxx @ 2018-07-23 21:55:36
```cpp
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define SET(x, a) memset(x, a, sizeof x);
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pld pair<ld, ld>
const ll MOD = 1000000007;
const ll INF = 1000000000;
template <class T> inline void read(T &x) {
char c;
int flag = 1;
while ((c = getchar()) < '0' || c > '9')
if (c == '-')
flag *= -1;
x = c - '0';
while ((c = getchar()) >= '0' && c <= '9')
x = x * 10 + c - '0';
x *= flag;
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int tree[n + 5], dp[n + 5];
for (int i = 1; i <= n; ++i)
cin >> tree[i];
int m;
cin >> m;
while (m--) {
int y;
cin >> y;
for (int i = 0; i <= n; ++i)
dp[i] = 1e9;
dp[1] = 0;
for (int i = 2; i <= n; ++i) {
for (int j = max(1, i - y); j < i; ++j) {
dp[i] = min(dp[i], dp[j] + (tree[j] <= tree[i]));
}
}
cout << dp[n] << endl;
}
}
```
by lckcode @ 2018-07-23 21:58:29
@[_WA自动机_](/space/show?uid=82363) 你学一学pascal嘛,很容易的。
by willbe233 @ 2018-07-23 21:58:37