답안 #918308

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918308 2024-01-29T15:13:44 Z Aiperiii Global Warming (CEOI18_glo) C++14
100 / 100
92 ms 10180 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
   ios_base::sync_with_stdio();
   cin.tie(0);cout.tie(0);
   int n,x;
   cin>>n>>x;
   vector <int> a(n);
   for(int i=0;i<n;i++)cin>>a[i];
   vector <int> v(n+1,1e18),v2(n+1,1e18);
   vector <int> l(n+1),r(n+1);
   v[0]=-1e18;
   v2[0]=-1e18;
   for(int i=0;i<n;i++){
      auto pos=lower_bound(all(v),a[i])-v.begin();
      l[i]=pos;
      v[pos]=a[i];
   }
   for(int i=n-1;i>=0;i--){
      auto pos=lower_bound(all(v2),-(a[i]-x))-v2.begin();
      r[i]=pos;
      pos=lower_bound(all(v2),-a[i])-v2.begin();
      v2[pos]=-a[i];
   }
   int mx=0;
   for(int i=0;i<n;i++){
      mx=max(mx,l[i]+r[i]-1);
   }
   cout<<mx<<"\n";
}
/*
8 10
7 3 5 12 2 7 3 4
 */
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 432 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 432 KB Output is correct
17 Correct 0 ms 344 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 440 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 10064 KB Output is correct
2 Correct 87 ms 10068 KB Output is correct
3 Correct 87 ms 10160 KB Output is correct
4 Correct 89 ms 10180 KB Output is correct
5 Correct 65 ms 9280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 2652 KB Output is correct
2 Correct 21 ms 2728 KB Output is correct
3 Correct 25 ms 2652 KB Output is correct
4 Correct 16 ms 2652 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 20 ms 2652 KB Output is correct
7 Correct 19 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 5204 KB Output is correct
2 Correct 39 ms 5176 KB Output is correct
3 Correct 82 ms 10068 KB Output is correct
4 Correct 66 ms 9296 KB Output is correct
5 Correct 31 ms 4692 KB Output is correct
6 Correct 61 ms 9040 KB Output is correct
7 Correct 70 ms 9716 KB Output is correct
8 Correct 38 ms 5200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 432 KB Output is correct
17 Correct 0 ms 344 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 440 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 436 KB Output is correct
27 Correct 87 ms 10064 KB Output is correct
28 Correct 87 ms 10068 KB Output is correct
29 Correct 87 ms 10160 KB Output is correct
30 Correct 89 ms 10180 KB Output is correct
31 Correct 65 ms 9280 KB Output is correct
32 Correct 21 ms 2652 KB Output is correct
33 Correct 21 ms 2728 KB Output is correct
34 Correct 25 ms 2652 KB Output is correct
35 Correct 16 ms 2652 KB Output is correct
36 Correct 0 ms 436 KB Output is correct
37 Correct 20 ms 2652 KB Output is correct
38 Correct 19 ms 2648 KB Output is correct
39 Correct 40 ms 5204 KB Output is correct
40 Correct 39 ms 5176 KB Output is correct
41 Correct 82 ms 10068 KB Output is correct
42 Correct 66 ms 9296 KB Output is correct
43 Correct 31 ms 4692 KB Output is correct
44 Correct 61 ms 9040 KB Output is correct
45 Correct 70 ms 9716 KB Output is correct
46 Correct 38 ms 5200 KB Output is correct
47 Correct 43 ms 5304 KB Output is correct
48 Correct 46 ms 5312 KB Output is correct
49 Correct 92 ms 10068 KB Output is correct
50 Correct 63 ms 9308 KB Output is correct
51 Correct 50 ms 7104 KB Output is correct
52 Correct 64 ms 9300 KB Output is correct
53 Correct 63 ms 9404 KB Output is correct
54 Correct 76 ms 10068 KB Output is correct
55 Correct 79 ms 10072 KB Output is correct