Submission #961124

# Submission time Handle Problem Language Result Execution time Memory
961124 2024-04-11T14:15:41 Z vjudge1 Financial Report (JOI21_financial) C++17
0 / 100
4000 ms 23888 KB
#include<bits/stdc++.h>
#define INF 1e9
#define fi first
#define se second
#define FOR(i, k, n) for(int i = k; i <= n; i++)
#define FOR1(i, k, n) for(int i = k; i >= n; i--)
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define vll vector<ll>
#define pll pair<ll, ll>
#define re return 0
#define mii map<int, int>
#define input "DANCE.inp"
#define output "DANCE.out"
#define rf 	freopen(input, "r", stdin); freopen(output, "w", stdout)
using namespace std;
const int maxn = 3e5 + 5;
const int mod = 1e9 + 7;
pll T[maxn * 4];
int a[maxn];
int dp[maxn];
void update(int id, int l, int r, int pos, int val, int val1)
{
	if(l == r)
	{
		T[id].fi = val;
		T[id].se = val1;
		return;
	}
	int mid = (l + r) / 2;
	if(pos <= mid)
		update(id * 2, l, mid, pos, val, val1);
	else
		update(id * 2 + 1, mid + 1, r, pos, val, val1);
	T[id].fi = max(T[id * 2].fi, T[id * 2 + 1].fi);
	T[id].se = max(T[id * 2].se, T[id * 2 + 1].se);
}
int get(int id, int l, int r, int u, int v, int val)
{
	if(l > v || r < u)
		return 0;
	if(l >= u && r <= v && T[id].se < val)
		return T[id].fi;
	if(l == r)
		return 0;
	int mid = (l + r) / 2;
	return max(get(id * 2, l, mid, u, v, val), get(id * 2 + 1, mid + 1, r, u, v, val));
}
int main()
{
	fastio;
	int n, d;
	cin >> n >> d;
	FOR(i, 1, n)
		cin >> a[i];
	dp[1] = 1;
	update(1, 1, n, 1, dp[1], a[1]);
	FOR(i, 2, n)
	{
		int res = get(1, 1, n, max(1, i - d), i - 1, a[i]);
		dp[i] = res + 1;
		update(1, 1, n, i, dp[i], a[i]);
	}
	int ans = 0;
	FOR(i, 1, n)
		ans = max(ans, dp[i]);
	cout << ans;
	re;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4556 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4440 KB Output is correct
15 Incorrect 1 ms 4444 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4556 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4440 KB Output is correct
15 Incorrect 1 ms 4444 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4556 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4440 KB Output is correct
15 Incorrect 1 ms 4444 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 111 ms 23888 KB Output is correct
2 Incorrect 98 ms 23692 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4096 ms 14304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4556 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4440 KB Output is correct
15 Incorrect 1 ms 4444 KB Output isn't correct
16 Halted 0 ms 0 KB -