이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0), cin.sync_with_stdio(0)
const int MN = 300005;
int n, d, a[MN], ans = 1, bit[MN], dp[MN], dead[MN];
vector<int> xs;
map<int, int> mp;
void upd(int x, int val) {
for (int i = x; i < MN; i += i & -i) bit[i] = max(bit[i], val);
}
int qry(int x) {
int ret = 0;
for (int i = x; i > 0; i -= i & -i) ret = max(ret, bit[i]);
return ret;
}
int32_t main() {
boost();
cin >> n >> d;
for (int i = 1; i <= n; i++) cin >> a[i], xs.push_back(a[i]);
sort(xs.begin(), xs.end());
xs.erase(unique(xs.begin(), xs.end()), xs.end());
for (int i = 0; i < xs.size(); i++) mp[xs[i]] = i + 1;
for (int i = 1; i <= n; i++) {
dp[i] = 1, dead[i] = i;
for (int j = 1; j < i; j++) {
if (dead[j] < i - d) continue;
if (a[j] < a[i]) dp[i] = max(dp[i], dp[j] + 1);
else dead[j] = i;
}
ans = max(ans, dp[i]);
}
printf("%lld\n", ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int32_t main()':
Main.cpp:35:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (int i = 0; i < xs.size(); i++) mp[xs[i]] = i + 1;
| ~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |