Submission #70997

# Submission time Handle Problem Language Result Execution time Memory
70997 2018-08-24T01:52:55 Z 윤교준(#2204) Global Warming (CEOI18_glo) C++11
62 / 100
73 ms 6900 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;

const bool debug = 0;
const int MAXN = 200005;

vector<ll> LISV, LDSV;
int B[MAXN]; ll C[MAXN];

ll A[MAXN];

int N, K, Ans;

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> K;
	for(int i = 1; i <= N; i++) cin >> A[i];

	for(int i = 1; i <= N; i++) {
		int t = int(lower_bound(allv(LISV), A[i]) - LISV.begin());
		B[i] = t;
		if(sz(LISV) <= t) {
			C[i] = -INFLL;
			LISV.eb(A[i]);
		} else {
			C[i] = LISV[t];
			LISV[t] = A[i];
		}
	}
	Ans = sz(LISV);

	for(int i = N; i; i--) {
		int t = int(lower_bound(allv(LDSV), -A[i]) - LDSV.begin());
		if(sz(LDSV) <= t) LDSV.eb(-A[i]); else LDSV[t] = -A[i];

		ll x = -LDSV.back();
		if(C[i] <= -INFLL) {
			LISV.pop_back();
		} else {
			LISV[B[i]] = C[i];
		}

		if(debug) {
			printf("LDS : ");
			for(int v : LDSV) printf("%d ", -v);
			puts("");
			printf("LIS : ");
			for(int v : LISV) printf("%d ", v);
			puts("");
		}

		upmax(Ans, sz(LDSV) + int(lower_bound(allv(LISV), x + K) - LISV.begin()));
		
		if(!LISV.empty())
			upmax(Ans, sz(LISV) + int(lower_bound(allv(LDSV), K - LISV.back()) - LDSV.begin()));
	}
	upmax(Ans, sz(LDSV));

	cout << Ans << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 480 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 3 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 3 ms 524 KB Output is correct
8 Correct 3 ms 572 KB Output is correct
9 Correct 3 ms 616 KB Output is correct
10 Correct 3 ms 616 KB Output is correct
11 Correct 2 ms 616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 480 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 3 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 3 ms 524 KB Output is correct
8 Correct 3 ms 572 KB Output is correct
9 Correct 3 ms 616 KB Output is correct
10 Correct 3 ms 616 KB Output is correct
11 Correct 2 ms 616 KB Output is correct
12 Correct 2 ms 616 KB Output is correct
13 Correct 4 ms 620 KB Output is correct
14 Correct 3 ms 620 KB Output is correct
15 Correct 3 ms 620 KB Output is correct
16 Correct 2 ms 620 KB Output is correct
17 Correct 2 ms 620 KB Output is correct
18 Correct 2 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 480 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 3 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 3 ms 524 KB Output is correct
8 Correct 3 ms 572 KB Output is correct
9 Correct 3 ms 616 KB Output is correct
10 Correct 3 ms 616 KB Output is correct
11 Correct 2 ms 616 KB Output is correct
12 Correct 2 ms 616 KB Output is correct
13 Correct 4 ms 620 KB Output is correct
14 Correct 3 ms 620 KB Output is correct
15 Correct 3 ms 620 KB Output is correct
16 Correct 2 ms 620 KB Output is correct
17 Correct 2 ms 620 KB Output is correct
18 Correct 2 ms 620 KB Output is correct
19 Correct 3 ms 636 KB Output is correct
20 Incorrect 3 ms 636 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 4584 KB Output is correct
2 Correct 73 ms 4584 KB Output is correct
3 Correct 65 ms 4584 KB Output is correct
4 Correct 68 ms 4584 KB Output is correct
5 Correct 57 ms 6900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 6900 KB Output is correct
2 Correct 18 ms 6900 KB Output is correct
3 Correct 18 ms 6900 KB Output is correct
4 Correct 17 ms 6900 KB Output is correct
5 Correct 3 ms 6900 KB Output is correct
6 Correct 14 ms 6900 KB Output is correct
7 Correct 17 ms 6900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 6900 KB Output is correct
2 Correct 32 ms 6900 KB Output is correct
3 Correct 67 ms 6900 KB Output is correct
4 Correct 59 ms 6900 KB Output is correct
5 Correct 35 ms 6900 KB Output is correct
6 Correct 60 ms 6900 KB Output is correct
7 Correct 55 ms 6900 KB Output is correct
8 Correct 31 ms 6900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 480 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 3 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 3 ms 524 KB Output is correct
8 Correct 3 ms 572 KB Output is correct
9 Correct 3 ms 616 KB Output is correct
10 Correct 3 ms 616 KB Output is correct
11 Correct 2 ms 616 KB Output is correct
12 Correct 2 ms 616 KB Output is correct
13 Correct 4 ms 620 KB Output is correct
14 Correct 3 ms 620 KB Output is correct
15 Correct 3 ms 620 KB Output is correct
16 Correct 2 ms 620 KB Output is correct
17 Correct 2 ms 620 KB Output is correct
18 Correct 2 ms 620 KB Output is correct
19 Correct 3 ms 636 KB Output is correct
20 Incorrect 3 ms 636 KB Output isn't correct
21 Halted 0 ms 0 KB -