답안 #556852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556852 2022-05-04T07:24:22 Z loctildore Global Warming (CEOI18_glo) C++14
100 / 100
176 ms 14412 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define endl '\n'
#define all(x) begin(x), end(x)
#define bitm 262144
int n,x,maximum;
int val[200069];
int lis[200069];
int bit[262169];
vector<int> compress;
unordered_map<int,int> um;
void addl(int i, int y) {
  while (i<=bitm) {
    bit[i]=max(bit[i],y);
    i+=(i&-i);
  }
}
int findl(int i) {
  int rtn=0;
  while (i) {
    rtn=max(rtn,bit[i]);
    i-=(i&-i);
  }
  return rtn;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  for (int i = 1; i < 200069; i++) {
    lis[i]=INT_MAX;
  }
  cin>>n>>x;
  for (int i = 0; i < n; i++) {
    cin>>val[i];
    compress.push_back(val[i]);
  }
  sort(all(compress));
  for (int i = 0; i < n; i++) {
    um[compress[i]]=i+1;
  }
  for (int i = 0; i < n; i++) {
    int tmp=lower_bound(lis,lis+200069,val[i]+x)-lis;
    tmp=max(tmp,findl(um[val[i]]-1)+1);
    addl(um[val[i]],tmp);
    maximum=max(maximum,tmp);

    tmp=lower_bound(lis,lis+200069,val[i])-lis;
    lis[tmp]=val[i];
    maximum=max(maximum,tmp);
  }
  cout<<maximum<<endl;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1108 KB Output is correct
21 Correct 1 ms 1120 KB Output is correct
22 Correct 2 ms 1120 KB Output is correct
23 Correct 1 ms 1120 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 168 ms 12388 KB Output is correct
2 Correct 176 ms 12452 KB Output is correct
3 Correct 150 ms 12436 KB Output is correct
4 Correct 174 ms 12356 KB Output is correct
5 Correct 97 ms 7592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 3936 KB Output is correct
2 Correct 29 ms 3972 KB Output is correct
3 Correct 28 ms 3868 KB Output is correct
4 Correct 16 ms 2772 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 14 ms 3124 KB Output is correct
7 Correct 25 ms 4344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 6700 KB Output is correct
2 Correct 67 ms 6716 KB Output is correct
3 Correct 133 ms 12384 KB Output is correct
4 Correct 71 ms 7524 KB Output is correct
5 Correct 33 ms 7284 KB Output is correct
6 Correct 56 ms 13240 KB Output is correct
7 Correct 59 ms 13864 KB Output is correct
8 Correct 59 ms 7656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1108 KB Output is correct
21 Correct 1 ms 1120 KB Output is correct
22 Correct 2 ms 1120 KB Output is correct
23 Correct 1 ms 1120 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 168 ms 12388 KB Output is correct
28 Correct 176 ms 12452 KB Output is correct
29 Correct 150 ms 12436 KB Output is correct
30 Correct 174 ms 12356 KB Output is correct
31 Correct 97 ms 7592 KB Output is correct
32 Correct 31 ms 3936 KB Output is correct
33 Correct 29 ms 3972 KB Output is correct
34 Correct 28 ms 3868 KB Output is correct
35 Correct 16 ms 2772 KB Output is correct
36 Correct 1 ms 1108 KB Output is correct
37 Correct 14 ms 3124 KB Output is correct
38 Correct 25 ms 4344 KB Output is correct
39 Correct 76 ms 6700 KB Output is correct
40 Correct 67 ms 6716 KB Output is correct
41 Correct 133 ms 12384 KB Output is correct
42 Correct 71 ms 7524 KB Output is correct
43 Correct 33 ms 7284 KB Output is correct
44 Correct 56 ms 13240 KB Output is correct
45 Correct 59 ms 13864 KB Output is correct
46 Correct 59 ms 7656 KB Output is correct
47 Correct 67 ms 7708 KB Output is correct
48 Correct 62 ms 7688 KB Output is correct
49 Correct 149 ms 14412 KB Output is correct
50 Correct 76 ms 8668 KB Output is correct
51 Correct 56 ms 8248 KB Output is correct
52 Correct 67 ms 13668 KB Output is correct
53 Correct 60 ms 13696 KB Output is correct
54 Correct 66 ms 14396 KB Output is correct
55 Correct 123 ms 14336 KB Output is correct