답안 #748658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
748658 2023-05-26T17:17:21 Z pera Global Warming (CEOI18_glo) C++14
100 / 100
61 ms 6972 KB
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

#define int ll

const ll mod = 1e9 + 7;


main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int n , x;cin >> n >> x;
	vector<int> a(n) , s(n);
	vector<int> dp(n , LLONG_MAX);
	int ans = 0;
	for(int i = 0;i < n;i ++){
		cin >> a[i];
		int w = lower_bound(all(dp) , a[i]) - dp.begin();
		dp[w] = a[i];
		s[i] = w + 1;
		ans = max(ans , s[i]);
	}
	for(int i = 0;i < n;i ++) dp[i] = LLONG_MAX;
	for(int i = n - 1;i > -1;i --){
		int j = lower_bound(all(dp) , x - a[i]) - dp.begin();
		int y = lower_bound(all(dp) , -a[i]) - dp.begin();
		//cout << s[i] << " " << j << endl;
		ans = max(ans , s[i] + j);
		dp[y] = -a[i];
	}
	cout << ans << endl;
}

Compilation message

glo.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 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 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 1 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 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 4948 KB Output is correct
2 Correct 49 ms 4948 KB Output is correct
3 Correct 59 ms 5016 KB Output is correct
4 Correct 61 ms 5016 KB Output is correct
5 Correct 37 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1492 KB Output is correct
2 Correct 12 ms 1512 KB Output is correct
3 Correct 13 ms 1488 KB Output is correct
4 Correct 11 ms 1504 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 9 ms 1748 KB Output is correct
7 Correct 11 ms 2000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2644 KB Output is correct
2 Correct 24 ms 3568 KB Output is correct
3 Correct 51 ms 6928 KB Output is correct
4 Correct 42 ms 6176 KB Output is correct
5 Correct 25 ms 3160 KB Output is correct
6 Correct 36 ms 5976 KB Output is correct
7 Correct 39 ms 6568 KB Output is correct
8 Correct 24 ms 3668 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 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 49 ms 4948 KB Output is correct
28 Correct 49 ms 4948 KB Output is correct
29 Correct 59 ms 5016 KB Output is correct
30 Correct 61 ms 5016 KB Output is correct
31 Correct 37 ms 4948 KB Output is correct
32 Correct 11 ms 1492 KB Output is correct
33 Correct 12 ms 1512 KB Output is correct
34 Correct 13 ms 1488 KB Output is correct
35 Correct 11 ms 1504 KB Output is correct
36 Correct 0 ms 324 KB Output is correct
37 Correct 9 ms 1748 KB Output is correct
38 Correct 11 ms 2000 KB Output is correct
39 Correct 23 ms 2644 KB Output is correct
40 Correct 24 ms 3568 KB Output is correct
41 Correct 51 ms 6928 KB Output is correct
42 Correct 42 ms 6176 KB Output is correct
43 Correct 25 ms 3160 KB Output is correct
44 Correct 36 ms 5976 KB Output is correct
45 Correct 39 ms 6568 KB Output is correct
46 Correct 24 ms 3668 KB Output is correct
47 Correct 25 ms 3540 KB Output is correct
48 Correct 25 ms 3572 KB Output is correct
49 Correct 51 ms 6920 KB Output is correct
50 Correct 41 ms 6184 KB Output is correct
51 Correct 37 ms 4608 KB Output is correct
52 Correct 38 ms 6228 KB Output is correct
53 Correct 33 ms 6228 KB Output is correct
54 Correct 36 ms 6928 KB Output is correct
55 Correct 42 ms 6972 KB Output is correct