Submission #775787

# Submission time Handle Problem Language Result Execution time Memory
775787 2023-07-07T01:00:47 Z vgoofficial Global Warming (CEOI18_glo) C++14
100 / 100
53 ms 5720 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0);
    int n,x;
    cin >> n >> x;
    int temps[n];
    for(int i = 0; i < n; i++) cin >> temps[i];
    int left[n], right[n];
    vector<int> magic;
    magic.push_back(temps[0]);
    left[0]=1;
    for(int i = 1; i < n; i++) {
        int lb = lower_bound(begin(magic), end(magic), temps[i])-begin(magic);
        if(lb==magic.size()) {
            magic.push_back(temps[i]);
        } else {
            magic[lb]=temps[i];
        }
        left[i]=lb+1;
    }
    vector<int> magic2;
    magic2.push_back(-temps[n-1]);
    right[n-1]=0;
    for(int i = n-2; i >= 0; i--) {
        //for(int i: magic2) cout << i << " ";
        int rb = lower_bound(begin(magic2), end(magic2), -temps[i]+x)-begin(magic2);
        //cout << -temps[i]+x<< " " << rb << endl;
        right[i]=rb;
        int insert = lower_bound(begin(magic2), end(magic2), -temps[i])-begin(magic2);
        if(insert==magic2.size()) {
            magic2.push_back(-temps[i]);
        } else {
            magic2[insert]=-temps[i];
        }
    }
    int max = 0;
    for(int i = 0; i < n; i++) {
        max=std::max(max,left[i]+right[i]);
    }
    cout << max << endl;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:17:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         if(lb==magic.size()) {
      |            ~~^~~~~~~~~~~~~~
glo.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if(insert==magic2.size()) {
      |            ~~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 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 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 4588 KB Output is correct
2 Correct 45 ms 4532 KB Output is correct
3 Correct 45 ms 4544 KB Output is correct
4 Correct 44 ms 4572 KB Output is correct
5 Correct 22 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1388 KB Output is correct
2 Correct 11 ms 1364 KB Output is correct
3 Correct 11 ms 1388 KB Output is correct
4 Correct 7 ms 1444 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 5 ms 1436 KB Output is correct
7 Correct 12 ms 1384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2360 KB Output is correct
2 Correct 19 ms 2356 KB Output is correct
3 Correct 38 ms 4516 KB Output is correct
4 Correct 22 ms 4964 KB Output is correct
5 Correct 11 ms 2648 KB Output is correct
6 Correct 22 ms 4884 KB Output is correct
7 Correct 25 ms 5516 KB Output is correct
8 Correct 15 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 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 212 KB Output is correct
27 Correct 47 ms 4588 KB Output is correct
28 Correct 45 ms 4532 KB Output is correct
29 Correct 45 ms 4544 KB Output is correct
30 Correct 44 ms 4572 KB Output is correct
31 Correct 22 ms 4948 KB Output is correct
32 Correct 11 ms 1388 KB Output is correct
33 Correct 11 ms 1364 KB Output is correct
34 Correct 11 ms 1388 KB Output is correct
35 Correct 7 ms 1444 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 5 ms 1436 KB Output is correct
38 Correct 12 ms 1384 KB Output is correct
39 Correct 19 ms 2360 KB Output is correct
40 Correct 19 ms 2356 KB Output is correct
41 Correct 38 ms 4516 KB Output is correct
42 Correct 22 ms 4964 KB Output is correct
43 Correct 11 ms 2648 KB Output is correct
44 Correct 22 ms 4884 KB Output is correct
45 Correct 25 ms 5516 KB Output is correct
46 Correct 15 ms 2388 KB Output is correct
47 Correct 22 ms 2356 KB Output is correct
48 Correct 22 ms 2352 KB Output is correct
49 Correct 53 ms 4580 KB Output is correct
50 Correct 21 ms 4924 KB Output is correct
51 Correct 21 ms 4052 KB Output is correct
52 Correct 22 ms 5044 KB Output is correct
53 Correct 20 ms 5068 KB Output is correct
54 Correct 24 ms 5720 KB Output is correct
55 Correct 35 ms 4532 KB Output is correct