Submission #744566

# Submission time Handle Problem Language Result Execution time Memory
744566 2023-05-18T18:22:26 Z ajab_01 Global Warming (CEOI18_glo) C++17
10 / 100
69 ms 13176 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int N = 2e5 + 5;
const int INF = 1e9 + 1000;
int arr[N] , dp[N] , las[N] , last[N] , g[N] , f[N] , ls[N] , ans , n , x;

int32_t main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	fill(las , las + N , INF);
	fill(last , last + N , INF);
	fill(ls , ls + N , INF);
	cin >> n >> x;
	for(int i = 0 ; i < n ; i++)
		cin >> arr[i];
	for(int i = 0 ; i < n ; i++){
		int low = 0 , high = n;
		while(high - low > 1){
			int mid = (high + low) >> 1;
			if(las[mid] < arr[i])
				low = mid;
			else
				high = mid;
		}

		las[low + 1] = arr[i];
		dp[i] = low + 1;

		int l = 0 , r = n;
		while(r - l > 1){
			int mid = (r + l) >> 1;
			if(last[mid] < arr[i])
				l = mid;
			else
				r = mid;
		}

		g[i] = l + 1;
		last[low + 1] = arr[i] - x;
	}

	for(int i = 0 ; i < n ; i++){
		int low = 0 , high = n;
		while(high - low > 1){
			int mid = (high + low) >> 1;
			if(ls[mid] < arr[i])
				low = mid;
			else
				high = mid;
		}

		f[i] = low + 1;
		f[i] = max(f[i] , g[i]);
		ls[f[i]] = arr[i];
		ans = max(ans , f[i]);
	}

	cout << ans << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Incorrect 3 ms 4948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Incorrect 3 ms 4948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Incorrect 3 ms 4948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 64 ms 13076 KB Output is correct
2 Correct 62 ms 13072 KB Output is correct
3 Correct 65 ms 13128 KB Output is correct
4 Correct 69 ms 13108 KB Output is correct
5 Correct 59 ms 12364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 6988 KB Output is correct
2 Correct 18 ms 7088 KB Output is correct
3 Correct 20 ms 7028 KB Output is correct
4 Correct 18 ms 6852 KB Output is correct
5 Incorrect 3 ms 5044 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 9064 KB Output is correct
2 Correct 31 ms 9076 KB Output is correct
3 Incorrect 62 ms 13176 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Incorrect 3 ms 4948 KB Output isn't correct
3 Halted 0 ms 0 KB -