# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1111921 | 2024-11-13T10:39:03 Z | vjudge1 | Global Warming (CEOI18_glo) | C++17 | 44 ms | 4452 KB |
#include<bits/stdc++.h> using namespace std; const bool multiTest = false; #define task "C" #define fi first #define se second #define MASK(i) (1LL << (i)) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define BIT(mask, i) ((mask) >> (i) & 1) template<typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) a = b; else return 0; return 1; } template<typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) a = b; else return 0; return 1; } const int MAX = 200020; int n, x; int t[MAX]; int f[MAX]; void process(void) { cin >> n >> x; for (int i = 1; i <= n; ++i) { cin >> t[i]; } vector<int> dp; for (int i = 1; i <= n; ++i) { int pos = lower_bound(all(dp), t[i]) - dp.begin(); if (dp.size() == pos) dp.push_back(t[i]); else dp[pos] = t[i]; f[i] = pos + 1; } int res = *max_element(f + 1, f + 1 + n); dp.clear(); for (int i = n; i >= 1; --i) { int pos = lower_bound(all(dp), x - t[i]) - dp.begin(); maximize(res, pos + f[i]); pos = lower_bound(all(dp), -t[i]) - dp.begin(); if (dp.size() == pos) dp.push_back(-t[i]); else dp[pos] = -t[i]; } cout << res; } int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int nTest = 1; if (multiTest) cin >> nTest; while (nTest--) { process(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 464 KB | Output is correct |
16 | Correct | 1 ms | 336 KB | Output is correct |
17 | Correct | 1 ms | 336 KB | Output is correct |
18 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 464 KB | Output is correct |
16 | Correct | 1 ms | 336 KB | Output is correct |
17 | Correct | 1 ms | 336 KB | Output is correct |
18 | Correct | 1 ms | 336 KB | Output is correct |
19 | Correct | 1 ms | 336 KB | Output is correct |
20 | Correct | 1 ms | 336 KB | Output is correct |
21 | Correct | 1 ms | 508 KB | Output is correct |
22 | Correct | 1 ms | 336 KB | Output is correct |
23 | Correct | 1 ms | 336 KB | Output is correct |
24 | Correct | 1 ms | 336 KB | Output is correct |
25 | Correct | 1 ms | 336 KB | Output is correct |
26 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 1916 KB | Output is correct |
2 | Correct | 44 ms | 3912 KB | Output is correct |
3 | Correct | 37 ms | 3912 KB | Output is correct |
4 | Correct | 38 ms | 3920 KB | Output is correct |
5 | Correct | 21 ms | 3588 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 848 KB | Output is correct |
2 | Correct | 10 ms | 1104 KB | Output is correct |
3 | Correct | 12 ms | 1104 KB | Output is correct |
4 | Correct | 6 ms | 1360 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 6 ms | 1360 KB | Output is correct |
7 | Correct | 9 ms | 1164 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 1104 KB | Output is correct |
2 | Correct | 18 ms | 2224 KB | Output is correct |
3 | Correct | 36 ms | 3824 KB | Output is correct |
4 | Correct | 22 ms | 3540 KB | Output is correct |
5 | Correct | 12 ms | 2004 KB | Output is correct |
6 | Correct | 18 ms | 3536 KB | Output is correct |
7 | Correct | 23 ms | 4308 KB | Output is correct |
8 | Correct | 15 ms | 2128 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 464 KB | Output is correct |
16 | Correct | 1 ms | 336 KB | Output is correct |
17 | Correct | 1 ms | 336 KB | Output is correct |
18 | Correct | 1 ms | 336 KB | Output is correct |
19 | Correct | 1 ms | 336 KB | Output is correct |
20 | Correct | 1 ms | 336 KB | Output is correct |
21 | Correct | 1 ms | 508 KB | Output is correct |
22 | Correct | 1 ms | 336 KB | Output is correct |
23 | Correct | 1 ms | 336 KB | Output is correct |
24 | Correct | 1 ms | 336 KB | Output is correct |
25 | Correct | 1 ms | 336 KB | Output is correct |
26 | Correct | 1 ms | 336 KB | Output is correct |
27 | Correct | 37 ms | 1916 KB | Output is correct |
28 | Correct | 44 ms | 3912 KB | Output is correct |
29 | Correct | 37 ms | 3912 KB | Output is correct |
30 | Correct | 38 ms | 3920 KB | Output is correct |
31 | Correct | 21 ms | 3588 KB | Output is correct |
32 | Correct | 9 ms | 848 KB | Output is correct |
33 | Correct | 10 ms | 1104 KB | Output is correct |
34 | Correct | 12 ms | 1104 KB | Output is correct |
35 | Correct | 6 ms | 1360 KB | Output is correct |
36 | Correct | 1 ms | 336 KB | Output is correct |
37 | Correct | 6 ms | 1360 KB | Output is correct |
38 | Correct | 9 ms | 1164 KB | Output is correct |
39 | Correct | 18 ms | 1104 KB | Output is correct |
40 | Correct | 18 ms | 2224 KB | Output is correct |
41 | Correct | 36 ms | 3824 KB | Output is correct |
42 | Correct | 22 ms | 3540 KB | Output is correct |
43 | Correct | 12 ms | 2004 KB | Output is correct |
44 | Correct | 18 ms | 3536 KB | Output is correct |
45 | Correct | 23 ms | 4308 KB | Output is correct |
46 | Correct | 15 ms | 2128 KB | Output is correct |
47 | Correct | 21 ms | 2128 KB | Output is correct |
48 | Correct | 18 ms | 2128 KB | Output is correct |
49 | Correct | 37 ms | 3920 KB | Output is correct |
50 | Correct | 21 ms | 3540 KB | Output is correct |
51 | Correct | 21 ms | 3024 KB | Output is correct |
52 | Correct | 22 ms | 3792 KB | Output is correct |
53 | Correct | 32 ms | 3788 KB | Output is correct |
54 | Correct | 24 ms | 4452 KB | Output is correct |
55 | Correct | 31 ms | 3928 KB | Output is correct |