Submission #870773

# Submission time Handle Problem Language Result Execution time Memory
870773 2023-11-09T03:51:40 Z Darren0724 Global Warming (CEOI18_glo) C++17
100 / 100
118 ms 13776 KB
#include <bits/stdc++.h>
using namespace std;
#define LCBorz                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define x first
#define y second
const int N=400005;
struct BIT{
    vector<int> v=vector<int>(N);
    void add(int p,int x){
        for(int i=p;i<N;i+=i&(-i)){
            v[i]=max(v[i],x);
        }
    }
    int ask(int p){
        int ans=0;
        for(int i=p;i>0;i-=i&(-i)){
            ans=max(ans,v[i]);
        }
        return ans;
    }
};
int32_t main() {
    LCBorz;
    int n,x;cin>>n>>x;
    vector<int> v(n);
    vector<int> t;
    for(int i=0;i<n;i++){
        cin>>v[i];
        t.push_back(v[i]);
        t.push_back(v[i]+x);
    }
    sort(all(t));
    t.resize(unique(all(t))-t.begin());
    BIT b1,b2;
    int ans=0;
    for(int i=0;i<n;i++){
        int a1=lower_bound(all(t),v[i])-t.begin()+1;
        int a2=lower_bound(all(t),v[i]+x)-t.begin()+1;
        int t1=b1.ask(a1-1);
        int t2=max(b1.ask(a2-1),b2.ask(a2-1));
        b1.add(a1,t1+1);
        b2.add(a2,t2+1);
        ans=max(ans,t1+1);
        ans=max(ans,t2+1);
    }
    cout<<ans<<endl;

    
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6524 KB Output is correct
3 Correct 2 ms 6744 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6720 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6528 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6524 KB Output is correct
3 Correct 2 ms 6744 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6720 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6528 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6524 KB Output is correct
3 Correct 2 ms 6744 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6720 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6528 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 6748 KB Output is correct
20 Correct 2 ms 6748 KB Output is correct
21 Correct 2 ms 6744 KB Output is correct
22 Correct 2 ms 6748 KB Output is correct
23 Correct 2 ms 6748 KB Output is correct
24 Correct 2 ms 6748 KB Output is correct
25 Correct 3 ms 6748 KB Output is correct
26 Correct 2 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 13252 KB Output is correct
2 Correct 106 ms 13352 KB Output is correct
3 Correct 107 ms 13356 KB Output is correct
4 Correct 107 ms 13368 KB Output is correct
5 Correct 51 ms 12488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 8408 KB Output is correct
2 Correct 26 ms 8408 KB Output is correct
3 Correct 26 ms 8408 KB Output is correct
4 Correct 15 ms 8148 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 14 ms 8164 KB Output is correct
7 Correct 22 ms 8516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 9932 KB Output is correct
2 Correct 58 ms 10060 KB Output is correct
3 Correct 118 ms 13776 KB Output is correct
4 Correct 65 ms 13616 KB Output is correct
5 Correct 33 ms 9564 KB Output is correct
6 Correct 59 ms 12512 KB Output is correct
7 Correct 61 ms 13256 KB Output is correct
8 Correct 46 ms 10196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6524 KB Output is correct
3 Correct 2 ms 6744 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6720 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6528 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 6748 KB Output is correct
20 Correct 2 ms 6748 KB Output is correct
21 Correct 2 ms 6744 KB Output is correct
22 Correct 2 ms 6748 KB Output is correct
23 Correct 2 ms 6748 KB Output is correct
24 Correct 2 ms 6748 KB Output is correct
25 Correct 3 ms 6748 KB Output is correct
26 Correct 2 ms 6748 KB Output is correct
27 Correct 106 ms 13252 KB Output is correct
28 Correct 106 ms 13352 KB Output is correct
29 Correct 107 ms 13356 KB Output is correct
30 Correct 107 ms 13368 KB Output is correct
31 Correct 51 ms 12488 KB Output is correct
32 Correct 26 ms 8408 KB Output is correct
33 Correct 26 ms 8408 KB Output is correct
34 Correct 26 ms 8408 KB Output is correct
35 Correct 15 ms 8148 KB Output is correct
36 Correct 2 ms 6492 KB Output is correct
37 Correct 14 ms 8164 KB Output is correct
38 Correct 22 ms 8516 KB Output is correct
39 Correct 56 ms 9932 KB Output is correct
40 Correct 58 ms 10060 KB Output is correct
41 Correct 118 ms 13776 KB Output is correct
42 Correct 65 ms 13616 KB Output is correct
43 Correct 33 ms 9564 KB Output is correct
44 Correct 59 ms 12512 KB Output is correct
45 Correct 61 ms 13256 KB Output is correct
46 Correct 46 ms 10196 KB Output is correct
47 Correct 54 ms 9932 KB Output is correct
48 Correct 58 ms 10020 KB Output is correct
49 Correct 116 ms 13712 KB Output is correct
50 Correct 57 ms 13128 KB Output is correct
51 Correct 44 ms 11204 KB Output is correct
52 Correct 61 ms 13520 KB Output is correct
53 Correct 58 ms 12744 KB Output is correct
54 Correct 67 ms 13508 KB Output is correct
55 Correct 93 ms 13508 KB Output is correct