# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971872 | mannshah1211 | Financial Report (JOI21_financial) | C++17 | 4033 ms | 1048576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author: hashman
* created:
**/
#include <bits/stdc++.h>
using namespace std;
string to_string(string s) {
return '"' + s + '"';
}
string to_string(const char* s) {
return to_string((string) s);
}
string to_string(bool b) {
return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
void debug_out() {
cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
using Int = long long;
int main() {
int n, d;
scanf("%d%d", &n, &d);
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
vector<vector<bool>> pos(n + 1, vector<bool>(n + 1));
vector<int> dp(n + 1);
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
pos[i][j] = (a[i] < a[j]);
int prv = i;
for (int k = i; k <= j; k++) {
if (a[k] < a[j]) {
if (k - prv > d) {
pos[i][j] = false;
}
prv = k;
}
}
if (j - prv > d) {
pos[i][j] = false;
}
}
}
for (int i = 1; i <= n; i++) {
dp[i] = 1;
for (int j = i - 1; j >= 1; j--) {
if (pos[j][i]) {
dp[i] = max(dp[i], dp[j] + 1);
}
}
}
cout << *max_element(dp.begin() + 1, dp.end()) << '\n';
}
Compilation message (stderr)
# | 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... |