답안 #754357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754357 2023-06-07T14:45:23 Z sangeraf Global Warming (CEOI18_glo) C++17
100 / 100
129 ms 4500 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n, x; cin >> n >> x;
    vector<long long> v(n+1, 0);
    for(int i=1; i<=n; i++){
        cin >> v[i];
    }

    vector<long long> lj;
    lj.push_back(v[1]);
    vector<int> elol(n+1, 0);
    elol[1]=1;
    for(int i=2; i<=n; i++){
        int j = lower_bound(lj.begin(), lj.end(), v[i]) - lj.begin();
        elol[i]=j+1;
        if(j == lj.size()){
            lj.push_back(0);
        }
        lj[j]=v[i];
    }

    lj.clear();
    lj.push_back(-v[n]);
    vector<int> hatul(n+2, 0);
    if(v[n-1] < v[n]+x) hatul[n]=1;
    for(int i=n-1; i>0; i--){
        int j = lower_bound(lj.begin(), lj.end(), -v[i]) - lj.begin();
        if(j == lj.size()){
            lj.push_back(0);
        }
        lj[j]=-v[i];
        hatul[i] = lower_bound(lj.begin(), lj.end(), -1*(v[i-1]-x)) - lj.begin();
    }

    int maxi=0;
    for(int i=0; i<=n; i++){
        maxi=max(maxi, elol[i]+hatul[i+1]);
    }
    cout << maxi << endl;


    return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if(j == lj.size()){
      |            ~~^~~~~~~~~~~~
glo.cpp:30:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if(j == lj.size()){
      |            ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 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 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 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 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 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 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 312 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 3400 KB Output is correct
2 Correct 111 ms 3552 KB Output is correct
3 Correct 122 ms 3520 KB Output is correct
4 Correct 129 ms 3532 KB Output is correct
5 Correct 63 ms 4500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 980 KB Output is correct
2 Correct 26 ms 1104 KB Output is correct
3 Correct 30 ms 1100 KB Output is correct
4 Correct 19 ms 1404 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 17 ms 1480 KB Output is correct
7 Correct 25 ms 1100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 1852 KB Output is correct
2 Correct 52 ms 2116 KB Output is correct
3 Correct 102 ms 3580 KB Output is correct
4 Correct 66 ms 4480 KB Output is correct
5 Correct 34 ms 2472 KB Output is correct
6 Correct 57 ms 4208 KB Output is correct
7 Correct 85 ms 4204 KB Output is correct
8 Correct 49 ms 1996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 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 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 312 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 101 ms 3400 KB Output is correct
28 Correct 111 ms 3552 KB Output is correct
29 Correct 122 ms 3520 KB Output is correct
30 Correct 129 ms 3532 KB Output is correct
31 Correct 63 ms 4500 KB Output is correct
32 Correct 26 ms 980 KB Output is correct
33 Correct 26 ms 1104 KB Output is correct
34 Correct 30 ms 1100 KB Output is correct
35 Correct 19 ms 1404 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 17 ms 1480 KB Output is correct
38 Correct 25 ms 1100 KB Output is correct
39 Correct 48 ms 1852 KB Output is correct
40 Correct 52 ms 2116 KB Output is correct
41 Correct 102 ms 3580 KB Output is correct
42 Correct 66 ms 4480 KB Output is correct
43 Correct 34 ms 2472 KB Output is correct
44 Correct 57 ms 4208 KB Output is correct
45 Correct 85 ms 4204 KB Output is correct
46 Correct 49 ms 1996 KB Output is correct
47 Correct 54 ms 1924 KB Output is correct
48 Correct 50 ms 1968 KB Output is correct
49 Correct 102 ms 3572 KB Output is correct
50 Correct 67 ms 4416 KB Output is correct
51 Correct 49 ms 3636 KB Output is correct
52 Correct 71 ms 4400 KB Output is correct
53 Correct 65 ms 4400 KB Output is correct
54 Correct 88 ms 4396 KB Output is correct
55 Correct 97 ms 3532 KB Output is correct