제출 #479346

#제출 시각아이디문제언어결과실행 시간메모리
479346nicolaalexandraFinancial Report (JOI21_financial)C++14
0 / 100
4051 ms6272 KiB
#include <bits/stdc++.h> #define DIM 300010 using namespace std; pair <int,int> v[DIM]; int dp[DIM]; int n,d,i,j; inline int cmp (pair<int,int> a, pair<int,int> b){ if (a.first == b.first) return a.second > b.second; return a.first < b.first; } int main (){ //ifstream cin ("date.in"); //ofstream cout ("date.out"); cin>>n>>d; for (i=1;i<=n;i++){ cin>>v[i].first; v[i].second = i; } sort (v+1,v+n+1,cmp); dp[1] = 1; for (i=2;i<=n;i++){ dp[i] = 1; for (j=1;j<i;j++){ if (v[j].second < v[i].second && v[j].second + d >= v[i].second) dp[i] = max (dp[i],dp[j]+1); } } int sol = 0; for (i=1;i<=n;i++) sol = max (sol,dp[i]); cout<<sol; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...