# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
888125 | sleepntsheep | Financial Report (JOI21_financial) | C++17 | 34 ms | 7124 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.
#include <iostream>
#include <stack>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
#include <complex>
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using namespace std;
using pt = complex<f80>;
#define ALL(x) begin(x), end(x)
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
#define N 7003
int dp[N], lt[N];
int main()
{
ShinLena;
int n, d;
cin >> n >> d;
vector<int> a(n), c;
for (auto &x : a) cin >> x;
c = a;
sort(ALL(c));
for (auto &x : a) x = lower_bound(ALL(c), x) - c.begin();
memset(lt, 0xbf, sizeof lt);
for (int i = 0; i < n; ++i)
{
dp[i] = 1;
for (int j = 0; j < c.size(); ++j)
if (i - lt[j] <= d)
dp[i] = max(dp[lt[j]] + (j < a[i]), dp[i]);
for (int j = a[i]; j < c.size(); ++j) lt[i] = i;
}
cout << dp[n-1];
return 0;
}
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... |