# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
359331 | 2021-01-26T19:35:30 Z | Sparky_09 | Global Warming (CEOI18_glo) | C++17 | 70 ms | 7040 KB |
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<ll, ll> pii; typedef vector<ll> vi; typedef vector<pii> vpi; void usaco(string s){ freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); #ifdef LOCAL_DEFINE freopen("input.txt", "r", stdin); #endif ll n, x, v[200055], dp[200055]; cin >> n >> x; for (int i = 0; i < n; i++) cin >> v[i]; vector<ll> lis(n, INT_MAX); ll k = 0; for(int i = 0; i < n; i++){ int j = lower_bound(lis.begin(), lis.end(), v[i])-lis.begin(); lis[j] = v[i]; dp[i] = j+1; k = max(k, dp[i]); } for(ll& i: lis) i = INT_MAX; for(int i = n-1; i >= 0; i--){ int j = lower_bound(lis.begin(), lis.end(), -v[i]+x)-lis.begin(); int j2 = lower_bound(lis.begin(), lis.end(), -v[i])-lis.begin(); lis[j2] = -v[i]; k = max(k, dp[i]+j); } cout << k << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 69 ms | 7020 KB | Output is correct |
2 | Correct | 69 ms | 6892 KB | Output is correct |
3 | Correct | 69 ms | 6892 KB | Output is correct |
4 | Correct | 70 ms | 6892 KB | Output is correct |
5 | Correct | 49 ms | 6144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 2028 KB | Output is correct |
2 | Correct | 17 ms | 2028 KB | Output is correct |
3 | Correct | 17 ms | 2156 KB | Output is correct |
4 | Correct | 12 ms | 1772 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 13 ms | 1772 KB | Output is correct |
7 | Correct | 14 ms | 2028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 3716 KB | Output is correct |
2 | Correct | 31 ms | 3676 KB | Output is correct |
3 | Correct | 66 ms | 6892 KB | Output is correct |
4 | Correct | 52 ms | 6124 KB | Output is correct |
5 | Correct | 25 ms | 3308 KB | Output is correct |
6 | Correct | 43 ms | 5996 KB | Output is correct |
7 | Correct | 49 ms | 6764 KB | Output is correct |
8 | Correct | 26 ms | 3832 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 69 ms | 7020 KB | Output is correct |
28 | Correct | 69 ms | 6892 KB | Output is correct |
29 | Correct | 69 ms | 6892 KB | Output is correct |
30 | Correct | 70 ms | 6892 KB | Output is correct |
31 | Correct | 49 ms | 6144 KB | Output is correct |
32 | Correct | 16 ms | 2028 KB | Output is correct |
33 | Correct | 17 ms | 2028 KB | Output is correct |
34 | Correct | 17 ms | 2156 KB | Output is correct |
35 | Correct | 12 ms | 1772 KB | Output is correct |
36 | Correct | 1 ms | 364 KB | Output is correct |
37 | Correct | 13 ms | 1772 KB | Output is correct |
38 | Correct | 14 ms | 2028 KB | Output is correct |
39 | Correct | 33 ms | 3716 KB | Output is correct |
40 | Correct | 31 ms | 3676 KB | Output is correct |
41 | Correct | 66 ms | 6892 KB | Output is correct |
42 | Correct | 52 ms | 6124 KB | Output is correct |
43 | Correct | 25 ms | 3308 KB | Output is correct |
44 | Correct | 43 ms | 5996 KB | Output is correct |
45 | Correct | 49 ms | 6764 KB | Output is correct |
46 | Correct | 26 ms | 3832 KB | Output is correct |
47 | Correct | 36 ms | 3968 KB | Output is correct |
48 | Correct | 34 ms | 3692 KB | Output is correct |
49 | Correct | 70 ms | 6892 KB | Output is correct |
50 | Correct | 49 ms | 6124 KB | Output is correct |
51 | Correct | 39 ms | 4716 KB | Output is correct |
52 | Correct | 50 ms | 6252 KB | Output is correct |
53 | Correct | 46 ms | 6252 KB | Output is correct |
54 | Correct | 49 ms | 7040 KB | Output is correct |
55 | Correct | 58 ms | 7020 KB | Output is correct |