이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
//#define int long long
#define pii pair<int,int>
#define ret return
#define fr first
#define sc second
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define nosol puts("-1");
#define pb push_back
#define endi puts("");
#define ordered_set tree <int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N = 3e5+12,INF = 1e9+7;
int a[N],dp[1000][1000],t[N];
int main(){
int i,n,d,j,ans=0;
cin>>n>>d;
vector <int> v;
set <int> ss{-1};
map <int,int> mp;
for (i=1;i<=n;++i){
cin>>a[i];
ss.insert(a[i]);
}
int cnt = 0;
for (auto x:ss)
mp[x] = cnt++;
for (i=1;i<=n;++i)
a[i] = mp[a[i]];
set <pii> s;
for (i=1;i<=n;++i){
int mx = 0;
for (j=max(i-d,1);j<i;++j){
if (a[i] > a[j])
mx = max(mx,t[a[j]]);
}
t[a[i]] = mx+1;
ans = max(ans,mx+1);
}
cout <<ans;
}
# | 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... |