Submission #1000084

# Submission time Handle Problem Language Result Execution time Memory
1000084 2024-06-16T15:49:29 Z daffuwu Global Warming (CEOI18_glo) C++14
100 / 100
46 ms 3712 KB
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, x, t[200069], ans, r[200069];
vector<int> vc;

int main() 
{
    int i, j;
    scanf("%d%d", &n, &x);
    for (i=1; i<=n; i++)
    {
        scanf("%d", t+i);
    }
    for (i=n; i>=1; i--)
    {
        auto it = lower_bound(vc.begin(), vc.end(), -t[i]);
        if (it == vc.end()) 
        {
            vc.push_back(-t[i]);
            r[i] = vc.size();
        }  else 
        {
            *it = -t[i];
            r[i] = it-vc.begin()+1;
        }
    }
    vc.clear();
    for (i=1; i<=n; i++)
    {
        auto it = lower_bound(vc.begin(), vc.end(), t[i]);
        if (it == vc.end()) vc.push_back(t[i]);
        else *it = t[i];
        j = upper_bound(vc.begin(), vc.end(), t[i+1]+x-1)-vc.begin();
        ans = max(ans, j+r[i+1]);
    }
    printf("%d\n", ans);
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d%d", &n, &x);
      |     ~~~~~^~~~~~~~~~~~~~~~
glo.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%d", t+i);
      |         ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 448 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 448 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 456 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 3228 KB Output is correct
2 Correct 46 ms 3156 KB Output is correct
3 Correct 37 ms 3160 KB Output is correct
4 Correct 40 ms 3068 KB Output is correct
5 Correct 21 ms 3280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1112 KB Output is correct
2 Correct 12 ms 1328 KB Output is correct
3 Correct 9 ms 1116 KB Output is correct
4 Correct 6 ms 1368 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 5 ms 1280 KB Output is correct
7 Correct 7 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1884 KB Output is correct
2 Correct 17 ms 1784 KB Output is correct
3 Correct 45 ms 3436 KB Output is correct
4 Correct 21 ms 3272 KB Output is correct
5 Correct 10 ms 2008 KB Output is correct
6 Correct 18 ms 3144 KB Output is correct
7 Correct 21 ms 3660 KB Output is correct
8 Correct 14 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 448 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 456 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 40 ms 3228 KB Output is correct
28 Correct 46 ms 3156 KB Output is correct
29 Correct 37 ms 3160 KB Output is correct
30 Correct 40 ms 3068 KB Output is correct
31 Correct 21 ms 3280 KB Output is correct
32 Correct 9 ms 1112 KB Output is correct
33 Correct 12 ms 1328 KB Output is correct
34 Correct 9 ms 1116 KB Output is correct
35 Correct 6 ms 1368 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 5 ms 1280 KB Output is correct
38 Correct 7 ms 1116 KB Output is correct
39 Correct 18 ms 1884 KB Output is correct
40 Correct 17 ms 1784 KB Output is correct
41 Correct 45 ms 3436 KB Output is correct
42 Correct 21 ms 3272 KB Output is correct
43 Correct 10 ms 2008 KB Output is correct
44 Correct 18 ms 3144 KB Output is correct
45 Correct 21 ms 3660 KB Output is correct
46 Correct 14 ms 1880 KB Output is correct
47 Correct 21 ms 1880 KB Output is correct
48 Correct 22 ms 2140 KB Output is correct
49 Correct 37 ms 3268 KB Output is correct
50 Correct 21 ms 3272 KB Output is correct
51 Correct 18 ms 2772 KB Output is correct
52 Correct 21 ms 3128 KB Output is correct
53 Correct 19 ms 3288 KB Output is correct
54 Correct 23 ms 3712 KB Output is correct
55 Correct 39 ms 3156 KB Output is correct