mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 14:58:48 +00:00
1260. 【例9.4】拦截导弹(Noip1999)
http://ybt.ssoier.cn:8088/statusx.php?runidx=15563317
This commit is contained in:
parent
ef0302107f
commit
69b14c7514
36
ybt/1260/1260.cpp
Normal file
36
ybt/1260/1260.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 20005;
|
||||
|
||||
int n, a[N], f[N], ans1, ans2;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
while (cin >> a[++n]) {}
|
||||
|
||||
for (int i = 1; i < n; i++) {
|
||||
f[i] = 1;
|
||||
for (int j = 1; j < i; j++) {
|
||||
if (a[j] >= a[i]) f[i] = std::max(f[i], f[j] + 1);
|
||||
}
|
||||
ans1 = std::max(ans1, f[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] = std::max(f[i], f[j] + 1);
|
||||
}
|
||||
ans2 = std::max(ans2, f[i]);
|
||||
}
|
||||
|
||||
cout << ans1 << endl
|
||||
<< ans2 << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user