Submission #1021750

#TimeUsernameProblemLanguageResultExecution timeMemory
1021750ef10Global Warming (CEOI18_glo)C++17
Compilation error
0 ms0 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

#define LL long long

LL N, X;
LL A[200005];
LL PR[200005];
LL dp[200005];

int main() {
	cin >> N >> X;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	LL res = 0;
	dp[1] = A[1];
	LL E = 2;
	for (int i = 2; i <= N; i++) {
		int ind = lower_bound(dp+1,dp+E,A[i])-dp;
		PR[i]=ind;
		res = max(res,PR[i]);
		dp[ind] = A[i];
		if (ind==E) {
			E++;
		}
	}
	dp[1]=-A[N];
	E=2;
	for (int i = N-1; i>=1; i--) {
		int ind = lower_bound(dp+1,dp+E,X-A[i])-dp;
		res = max(res,PR[i]+ind-1);

		ind = lower_bound(dp+1,dp+E,-A[i])-dp;
		dp[ind]=-A[i];
		if (ind == E) {
			E++;
		}
	}
	cout << res << endl;
}
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

#define LL long long

LL N, X;
LL A[200005];
LL PR[200005];
LL dp[200005];

int main() {
	cin >> N >> X;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	LL res = 0;
	dp[1] = A[1];
	LL E = 2;
	for (int i = 2; i <= N; i++) {
		int ind = lower_bound(dp+1,dp+E,A[i])-dp;
		PR[i]=ind;
		res = max(res,PR[i]);
		dp[ind] = A[i];
		if (ind==E) {
			E++;
		}
	}
	dp[1]=-A[N];
	E=2;
	for (int i = N-1; i>=1; i--) {
		int ind = lower_bound(dp+1,dp+E,X-A[i])-dp;
		res = max(res,PR[i]+ind-1);

		ind = lower_bound(dp+1,dp+E,-A[i])-dp;
		dp[ind]=-A[i];
		if (ind == E) {
			E++;
		}
	}
	cout << res << endl;
}

Compilation message (stderr)

glo.cpp:51:4: error: redefinition of 'long long int N'
   51 | LL N, X;
      |    ^
glo.cpp:8:4: note: 'long long int N' previously declared here
    8 | LL N, X;
      |    ^
glo.cpp:51:7: error: redefinition of 'long long int X'
   51 | LL N, X;
      |       ^
glo.cpp:8:7: note: 'long long int X' previously declared here
    8 | LL N, X;
      |       ^
glo.cpp:52:4: error: redefinition of 'long long int A [200005]'
   52 | LL A[200005];
      |    ^
glo.cpp:9:4: note: 'long long int A [200005]' previously declared here
    9 | LL A[200005];
      |    ^
glo.cpp:53:4: error: redefinition of 'long long int PR [200005]'
   53 | LL PR[200005];
      |    ^~
glo.cpp:10:4: note: 'long long int PR [200005]' previously declared here
   10 | LL PR[200005];
      |    ^~
glo.cpp:54:4: error: redefinition of 'long long int dp [200005]'
   54 | LL dp[200005];
      |    ^~
glo.cpp:11:4: note: 'long long int dp [200005]' previously declared here
   11 | LL dp[200005];
      |    ^~
glo.cpp:56:5: error: redefinition of 'int main()'
   56 | int main() {
      |     ^~~~
glo.cpp:13:5: note: 'int main()' previously defined here
   13 | int main() {
      |     ^~~~