답안 #839888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
839888 2023-08-30T19:45:24 Z Mathandski Global Warming (CEOI18_glo) C++17
100 / 100
80 ms 4996 KB
#include <bits/stdc++.h> 
using namespace std;
#define pb push_back 
#define is insert
#define ll long long
#define V vector
#define MS multiset
#define PL pair<ll, ll>
#define F first
#define S second
#define PQ priority_queue
#define f0r(i, begin, end) for (ll i = begin; i < end; i ++) 
#define For(i, end, begin) for (ll i = end; i > begin; i --) 
#define all(x) x.begin(), x.end()
#define INF 1000000000000000000
#define inf 1000000000
#define MOD 998244353
#define len(x) (ll)x.size()
#define fileread(file) ifstream fin; fin.open((string)file + ".in"); ofstream fout; fout.open((string)file + ".out")
#define fastio ios_base::sync_with_stdio(0LL); cin.tie(nullptr)
template<typename T> istream& operator>>(istream& in, V<T>& a) {for(auto &x : a) in >> x; return in;};
template<typename T> ostream& operator<<(ostream& out, V<T>& a) {for(auto &x : a) out << x << ' '; return out;};
int main () {
	ll N, M, ans = 0;
	cin >> N >> M;
	V<ll> nums(N);
	cin >> nums;
	
	V<ll> dp[2];
	dp[0] = dp[1] = V<ll>(N + 1, INF);
	for (ll i : nums) {
		ll pos = lower_bound(dp[0].begin(), dp[0].end(), i) - dp[0].begin();
		dp[0][pos] = i;
		ans = max(ans, pos);

		ll pos2 = lower_bound(dp[1].begin(), dp[1].end(), i) - dp[1].begin();
		dp[1][pos2] = i;
		ans = max(ans, pos2);

		dp[1][pos] = min(dp[1][pos], i - M);
	}
	cout << ans + 1 << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 228 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 228 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 4996 KB Output is correct
2 Correct 78 ms 4992 KB Output is correct
3 Correct 76 ms 4924 KB Output is correct
4 Correct 77 ms 4940 KB Output is correct
5 Correct 53 ms 4928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1464 KB Output is correct
2 Correct 20 ms 1468 KB Output is correct
3 Correct 19 ms 1480 KB Output is correct
4 Correct 13 ms 1468 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 14 ms 1472 KB Output is correct
7 Correct 18 ms 1472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 2624 KB Output is correct
2 Correct 39 ms 2620 KB Output is correct
3 Correct 78 ms 4924 KB Output is correct
4 Correct 58 ms 4924 KB Output is correct
5 Correct 28 ms 2668 KB Output is correct
6 Correct 51 ms 4748 KB Output is correct
7 Correct 65 ms 4724 KB Output is correct
8 Correct 39 ms 2632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 228 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 78 ms 4996 KB Output is correct
28 Correct 78 ms 4992 KB Output is correct
29 Correct 76 ms 4924 KB Output is correct
30 Correct 77 ms 4940 KB Output is correct
31 Correct 53 ms 4928 KB Output is correct
32 Correct 20 ms 1464 KB Output is correct
33 Correct 20 ms 1468 KB Output is correct
34 Correct 19 ms 1480 KB Output is correct
35 Correct 13 ms 1468 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 14 ms 1472 KB Output is correct
38 Correct 18 ms 1472 KB Output is correct
39 Correct 39 ms 2624 KB Output is correct
40 Correct 39 ms 2620 KB Output is correct
41 Correct 78 ms 4924 KB Output is correct
42 Correct 58 ms 4924 KB Output is correct
43 Correct 28 ms 2668 KB Output is correct
44 Correct 51 ms 4748 KB Output is correct
45 Correct 65 ms 4724 KB Output is correct
46 Correct 39 ms 2632 KB Output is correct
47 Correct 44 ms 2612 KB Output is correct
48 Correct 39 ms 2632 KB Output is correct
49 Correct 80 ms 4992 KB Output is correct
50 Correct 56 ms 4992 KB Output is correct
51 Correct 45 ms 3772 KB Output is correct
52 Correct 57 ms 4944 KB Output is correct
53 Correct 54 ms 4932 KB Output is correct
54 Correct 67 ms 4932 KB Output is correct
55 Correct 72 ms 4940 KB Output is correct