Submission #1087116

#TimeUsernameProblemLanguageResultExecution timeMemory
1087116coldbr3wFinancial Report (JOI21_financial)C++17
48 / 100
69 ms860 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define ll int
#define pll pair<long long, long long>
#define pb push_back
#define F first
#define S second  
#define all(x) (x).begin(), (x).end()
 
const ll N = 7070;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll block = 350;
ll nxt[N], a[N], dp[N];
ll n,d;
void to_thic_cau(){
	cin >> n >> d;
	for(int i = 1; i <= n;i++) cin >> a[i];
	for(int i = 1; i <= n;i++){
		ll lst = i;
		for(int j = i + 1; j <= n;j++){
			if(j - lst > d) break;
			if(a[j] <= a[i]) lst = j;
			nxt[i] = j;
		}
	}
	ll res = 0;
	for(int i = 1; i <= n;i++){
		dp[i] = 1;
		for(int j = 1; j <= i - 1;j++) if(a[i] > a[j] && nxt[j] >= i) dp[i] = max(dp[i], dp[j] + 1);
		res = max(res, dp[i]);
	}
	cout << res << '\n';
}

signed main()   
{ 
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll tc = 1;
	//cin >> tc;
	while(tc--) to_thic_cau();
}

Compilation message (stderr)

Main.cpp:12:16: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   12 | const ll inf = 1e18;
      |                ^~~~
#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...