# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
441655 | 2021-07-05T17:23:56 Z | linkret | Global Warming (CEOI18_glo) | C++14 | 701 ms | 26900 KB |
#include <bits/stdc++.h> using namespace std; int h [300000]; int fen [500002]; vector <int> pom; map <int, int> comp; int dp1 [300000]; int dp2 [300000]; const int MAXN = 500000+1; //fenwick int query (int x){ int sol=0; for (x; x>0; x-= (x & -x)) sol=max (sol, fen[x]); return sol; } void add (int x, int val){ for (x; x<500002; x+= (x & -x)) fen [x]=max (fen[x], val); } int main(){ //input int n, x; cin >> n >> x; for (int i=0; i<n; i++) cin >> h[i]; //compression for (int i=0; i<n; i++) pom.push_back(h[i]); for (int i=0; i<n; i++) pom.push_back(h[i]+x); sort (pom.begin(), pom.end()); for (int i=0; i<pom.size(); i++) comp [pom[i]]=i+1; //precompute right dynamic for (int i=n-1; i>=0; i--){ int hi=comp[h[i]]; int height=MAXN-hi; dp2 [i]=query (height)+1; add (height+1, dp2[i]); } //for (int i=0; i<n; i++) cout << dp2[i] << " "; memset (fen, 0, sizeof (fen)); //computing result int sol=0; for (int i=0; i<n; i++){ int hi=comp[h[i]+x]; int res=query (hi)+dp2[i]; dp1 [i]=query (comp[h[i]])+1; add (comp[h[i]]+1, dp1[i]); sol=max (sol, res); } cout << sol << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2252 KB | Output is correct |
2 | Correct | 1 ms | 2252 KB | Output is correct |
3 | Correct | 1 ms | 2252 KB | Output is correct |
4 | Correct | 1 ms | 2252 KB | Output is correct |
5 | Correct | 1 ms | 2252 KB | Output is correct |
6 | Correct | 1 ms | 2252 KB | Output is correct |
7 | Correct | 1 ms | 2252 KB | Output is correct |
8 | Correct | 2 ms | 2252 KB | Output is correct |
9 | Correct | 1 ms | 2252 KB | Output is correct |
10 | Correct | 1 ms | 2252 KB | Output is correct |
11 | Correct | 1 ms | 2252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2252 KB | Output is correct |
2 | Correct | 1 ms | 2252 KB | Output is correct |
3 | Correct | 1 ms | 2252 KB | Output is correct |
4 | Correct | 1 ms | 2252 KB | Output is correct |
5 | Correct | 1 ms | 2252 KB | Output is correct |
6 | Correct | 1 ms | 2252 KB | Output is correct |
7 | Correct | 1 ms | 2252 KB | Output is correct |
8 | Correct | 2 ms | 2252 KB | Output is correct |
9 | Correct | 1 ms | 2252 KB | Output is correct |
10 | Correct | 1 ms | 2252 KB | Output is correct |
11 | Correct | 1 ms | 2252 KB | Output is correct |
12 | Correct | 1 ms | 2252 KB | Output is correct |
13 | Correct | 1 ms | 2252 KB | Output is correct |
14 | Correct | 1 ms | 2252 KB | Output is correct |
15 | Correct | 1 ms | 2252 KB | Output is correct |
16 | Correct | 1 ms | 2232 KB | Output is correct |
17 | Correct | 1 ms | 2252 KB | Output is correct |
18 | Correct | 1 ms | 2252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2252 KB | Output is correct |
2 | Correct | 1 ms | 2252 KB | Output is correct |
3 | Correct | 1 ms | 2252 KB | Output is correct |
4 | Correct | 1 ms | 2252 KB | Output is correct |
5 | Correct | 1 ms | 2252 KB | Output is correct |
6 | Correct | 1 ms | 2252 KB | Output is correct |
7 | Correct | 1 ms | 2252 KB | Output is correct |
8 | Correct | 2 ms | 2252 KB | Output is correct |
9 | Correct | 1 ms | 2252 KB | Output is correct |
10 | Correct | 1 ms | 2252 KB | Output is correct |
11 | Correct | 1 ms | 2252 KB | Output is correct |
12 | Correct | 1 ms | 2252 KB | Output is correct |
13 | Correct | 1 ms | 2252 KB | Output is correct |
14 | Correct | 1 ms | 2252 KB | Output is correct |
15 | Correct | 1 ms | 2252 KB | Output is correct |
16 | Correct | 1 ms | 2232 KB | Output is correct |
17 | Correct | 1 ms | 2252 KB | Output is correct |
18 | Correct | 1 ms | 2252 KB | Output is correct |
19 | Correct | 3 ms | 2380 KB | Output is correct |
20 | Correct | 3 ms | 2380 KB | Output is correct |
21 | Correct | 3 ms | 2380 KB | Output is correct |
22 | Correct | 2 ms | 2252 KB | Output is correct |
23 | Correct | 2 ms | 2252 KB | Output is correct |
24 | Correct | 2 ms | 2252 KB | Output is correct |
25 | Correct | 2 ms | 2252 KB | Output is correct |
26 | Correct | 2 ms | 2224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 533 ms | 15488 KB | Output is correct |
2 | Correct | 502 ms | 17444 KB | Output is correct |
3 | Correct | 512 ms | 17484 KB | Output is correct |
4 | Correct | 488 ms | 17456 KB | Output is correct |
5 | Correct | 213 ms | 11928 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 106 ms | 7904 KB | Output is correct |
2 | Correct | 114 ms | 8508 KB | Output is correct |
3 | Correct | 104 ms | 8312 KB | Output is correct |
4 | Correct | 50 ms | 5852 KB | Output is correct |
5 | Correct | 1 ms | 2252 KB | Output is correct |
6 | Correct | 59 ms | 5820 KB | Output is correct |
7 | Correct | 83 ms | 7600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 268 ms | 13568 KB | Output is correct |
2 | Correct | 283 ms | 14560 KB | Output is correct |
3 | Correct | 701 ms | 26900 KB | Output is correct |
4 | Correct | 237 ms | 16632 KB | Output is correct |
5 | Correct | 134 ms | 14100 KB | Output is correct |
6 | Correct | 273 ms | 25056 KB | Output is correct |
7 | Correct | 301 ms | 25564 KB | Output is correct |
8 | Correct | 198 ms | 14516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2252 KB | Output is correct |
2 | Correct | 1 ms | 2252 KB | Output is correct |
3 | Correct | 1 ms | 2252 KB | Output is correct |
4 | Correct | 1 ms | 2252 KB | Output is correct |
5 | Correct | 1 ms | 2252 KB | Output is correct |
6 | Correct | 1 ms | 2252 KB | Output is correct |
7 | Correct | 1 ms | 2252 KB | Output is correct |
8 | Correct | 2 ms | 2252 KB | Output is correct |
9 | Correct | 1 ms | 2252 KB | Output is correct |
10 | Correct | 1 ms | 2252 KB | Output is correct |
11 | Correct | 1 ms | 2252 KB | Output is correct |
12 | Correct | 1 ms | 2252 KB | Output is correct |
13 | Correct | 1 ms | 2252 KB | Output is correct |
14 | Correct | 1 ms | 2252 KB | Output is correct |
15 | Correct | 1 ms | 2252 KB | Output is correct |
16 | Correct | 1 ms | 2232 KB | Output is correct |
17 | Correct | 1 ms | 2252 KB | Output is correct |
18 | Correct | 1 ms | 2252 KB | Output is correct |
19 | Correct | 3 ms | 2380 KB | Output is correct |
20 | Correct | 3 ms | 2380 KB | Output is correct |
21 | Correct | 3 ms | 2380 KB | Output is correct |
22 | Correct | 2 ms | 2252 KB | Output is correct |
23 | Correct | 2 ms | 2252 KB | Output is correct |
24 | Correct | 2 ms | 2252 KB | Output is correct |
25 | Correct | 2 ms | 2252 KB | Output is correct |
26 | Correct | 2 ms | 2224 KB | Output is correct |
27 | Correct | 533 ms | 15488 KB | Output is correct |
28 | Correct | 502 ms | 17444 KB | Output is correct |
29 | Correct | 512 ms | 17484 KB | Output is correct |
30 | Correct | 488 ms | 17456 KB | Output is correct |
31 | Correct | 213 ms | 11928 KB | Output is correct |
32 | Correct | 106 ms | 7904 KB | Output is correct |
33 | Correct | 114 ms | 8508 KB | Output is correct |
34 | Correct | 104 ms | 8312 KB | Output is correct |
35 | Correct | 50 ms | 5852 KB | Output is correct |
36 | Correct | 1 ms | 2252 KB | Output is correct |
37 | Correct | 59 ms | 5820 KB | Output is correct |
38 | Correct | 83 ms | 7600 KB | Output is correct |
39 | Correct | 268 ms | 13568 KB | Output is correct |
40 | Correct | 283 ms | 14560 KB | Output is correct |
41 | Correct | 701 ms | 26900 KB | Output is correct |
42 | Correct | 237 ms | 16632 KB | Output is correct |
43 | Correct | 134 ms | 14100 KB | Output is correct |
44 | Correct | 273 ms | 25056 KB | Output is correct |
45 | Correct | 301 ms | 25564 KB | Output is correct |
46 | Correct | 198 ms | 14516 KB | Output is correct |
47 | Correct | 245 ms | 14476 KB | Output is correct |
48 | Correct | 269 ms | 14544 KB | Output is correct |
49 | Correct | 635 ms | 26888 KB | Output is correct |
50 | Correct | 212 ms | 16748 KB | Output is correct |
51 | Correct | 199 ms | 13088 KB | Output is correct |
52 | Correct | 272 ms | 16816 KB | Output is correct |
53 | Correct | 289 ms | 26176 KB | Output is correct |
54 | Correct | 341 ms | 26892 KB | Output is correct |
55 | Correct | 414 ms | 23836 KB | Output is correct |