Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
140698 | 朱悦晨 | 导弹拦截 | C++ | 通过 | 100 | 1 MS | 276 KB | 952 | 2024-03-30 17:18:39 |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int a[N], x, n, dp[N], maxn; int g[N], cnt; int main() { while (cin >> x) a[++n] = x; g[0] = 2e9; for (int i = 1; i <= n; i++) { if (a[i] <= g[cnt]) g[++cnt] = a[i]; else { int l = 1, r = cnt; while (l < r) { int mid = l + r >> 1; if (g[mid] < a[i]) r = mid; else l = mid + 1; } g[l] = a[i]; } } cout << cnt << " "; cnt = 0; g[0] = -2e9; for (int i = 1; i <= n; i++) { if (a[i] > g[cnt]) g[++cnt] = a[i]; else { int l = 1, r = cnt; while (l < r) { int mid = l + r >> 1; if (g[mid] >= a[i]) r = mid; else l = mid + 1; } g[l] = a[i]; } } cout << cnt << endl; }