# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
886665 | fanwen | Financial Report (JOI21_financial) | C++17 | 4049 ms | 7224 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 : bo may can 5 */
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define file(name) \
if(fopen(name".inp", "r")) \
freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
const int MAX = 3e5 + 5;
int n, D, A[MAX], dp[MAX];
void you_make_it(void) {
cin >> n >> D;
for (int i = 1; i <= n; ++i) cin >> A[i];
vector <int> comp(A + 1, A + n + 1);
sort(comp.begin(), comp.end());
comp.erase(unique(comp.begin(), comp.end()), comp.end());
for (int i = 1; i <= n; ++i) {
A[i] = upper_bound(comp.begin(), comp.end(), A[i]) - comp.begin() + 1;
}
for (int i = 1; i <= n; ++i) {
dp[i] = 1;
int d = 0;
for (int j = i - 1; j >= 1; --j) {
if(A[j] >= A[i]) d++;
else d = 0;
if(d >= D) break;
if(A[j] < A[i]) dp[i] = max(dp[i], dp[j] + 1);
}
}
cout << *max_element(dp + 1, dp + n + 1);
}
signed main() {
#ifdef LOCAL
freopen("TASK.inp", "r", stdin);
freopen("TASK.out", "w", stdout);
#endif
file("financial");
auto start_time = chrono::steady_clock::now();
cin.tie(0), cout.tie(0) -> sync_with_stdio(0);
you_make_it();
auto end_time = chrono::steady_clock::now();
cerr << "\nExecution time : " << chrono::duration_cast <chrono::milliseconds> (end_time - start_time).count() << "[ms]" << endl;
return (0 ^ 0);
}
// Dream it. Wish it. Do it.
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... |