답안 #644798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644798 2022-09-25T08:59:07 Z Karuk Global Warming (CEOI18_glo) C++14
100 / 100
138 ms 20428 KB
#include<bits/stdc++.h>
using namespace std;
long long max(long long &a,long long &b) {return a>b?a:b;}
int main() {
    long long n,x;cin>>n>>x;
    long long a[n];
    long long poslis[n];
    vector<long long>lis(n,1e18);
    vector<vector<long long> >history(n,{(long long)(1e18)});
    long long ans=0;
    for(int i=0;i<n;i++) {
        long long y;cin>>y;
        long long pos=lower_bound(lis.begin(),lis.end(),y)-lis.begin();
        history[pos].push_back(y);
        poslis[i]=pos;
        lis[pos]=y;
        ans=max(ans,pos+1);
    }
    vector<long long>revlis(n,1e18);
    for(int i=n-1;i>0;i--) {
        long long cur=history[poslis[i]].back();
        history[poslis[i]].pop_back();
        lis[poslis[i]]=history[poslis[i]].back();
        cur+=x;
        cur=-cur;
        long long pos=lower_bound(revlis.begin(),revlis.end(),cur)-revlis.begin();
        revlis[pos]=cur;
        cur=-cur;
        long long pos1=lower_bound(lis.begin(),lis.end(),cur)-lis.begin();
        ans=max(ans,pos1+pos+1);
    }
    cout<<ans<<endl;
    return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:6:15: warning: unused variable 'a' [-Wunused-variable]
    6 |     long long a[n];
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 292 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 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 292 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 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 300 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 212 KB Output is correct
16 Correct 1 ms 216 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 292 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 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 300 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 212 KB Output is correct
16 Correct 1 ms 216 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 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 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 20372 KB Output is correct
2 Correct 132 ms 20328 KB Output is correct
3 Correct 132 ms 20336 KB Output is correct
4 Correct 127 ms 20344 KB Output is correct
5 Correct 103 ms 18100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 5296 KB Output is correct
2 Correct 30 ms 5280 KB Output is correct
3 Correct 31 ms 5360 KB Output is correct
4 Correct 23 ms 4852 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 25 ms 4912 KB Output is correct
7 Correct 37 ms 5128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 9996 KB Output is correct
2 Correct 59 ms 10036 KB Output is correct
3 Correct 112 ms 20316 KB Output is correct
4 Correct 106 ms 18008 KB Output is correct
5 Correct 51 ms 9428 KB Output is correct
6 Correct 86 ms 17140 KB Output is correct
7 Correct 103 ms 17928 KB Output is correct
8 Correct 53 ms 10060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 292 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 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 300 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 212 KB Output is correct
16 Correct 1 ms 216 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 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 340 KB Output is correct
27 Correct 122 ms 20372 KB Output is correct
28 Correct 132 ms 20328 KB Output is correct
29 Correct 132 ms 20336 KB Output is correct
30 Correct 127 ms 20344 KB Output is correct
31 Correct 103 ms 18100 KB Output is correct
32 Correct 39 ms 5296 KB Output is correct
33 Correct 30 ms 5280 KB Output is correct
34 Correct 31 ms 5360 KB Output is correct
35 Correct 23 ms 4852 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 25 ms 4912 KB Output is correct
38 Correct 37 ms 5128 KB Output is correct
39 Correct 59 ms 9996 KB Output is correct
40 Correct 59 ms 10036 KB Output is correct
41 Correct 112 ms 20316 KB Output is correct
42 Correct 106 ms 18008 KB Output is correct
43 Correct 51 ms 9428 KB Output is correct
44 Correct 86 ms 17140 KB Output is correct
45 Correct 103 ms 17928 KB Output is correct
46 Correct 53 ms 10060 KB Output is correct
47 Correct 63 ms 10088 KB Output is correct
48 Correct 60 ms 10136 KB Output is correct
49 Correct 125 ms 20428 KB Output is correct
50 Correct 92 ms 18136 KB Output is correct
51 Correct 72 ms 13652 KB Output is correct
52 Correct 119 ms 18768 KB Output is correct
53 Correct 87 ms 18088 KB Output is correct
54 Correct 138 ms 18856 KB Output is correct
55 Correct 113 ms 20080 KB Output is correct