답안 #1057977

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1057977 2024-08-14T07:48:31 Z Malix Global Warming (CEOI18_glo) C++14
100 / 100
89 ms 4404 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
 
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))
 
ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;

int main() {   
    int n,m;cin>>n>>m;
    vi a(n),b,p(n);
    REP(i,0,n)cin>>a[i];
    REP(i,0,n)a[i]=-a[i];
    reverse(a.begin(),a.end());
    b.PB(a[0]);p[0]=0;
    REP(i,1,n){
        auto it2=lower_bound(b.begin(),b.end(),a[i]+m);
        p[i]=it2-b.begin();
        auto it=lower_bound(b.begin(),b.end(),a[i]);
        if(it==b.end()){
            b.PB(a[i]);
            continue;
        }
        int pos=it-b.begin();
        b[pos]=a[i];
    }
    reverse(a.begin(),a.end());
    REP(i,0,n)a[i]=-a[i];
    reverse(p.begin(),p.end());
    b.clear();
    b.PB(a[0]);
    int k=b.size();
    int ans=k+p[0];
    REP(i,1,n){
        auto it=lower_bound(b.begin(),b.end(),a[i]);
        if(it==b.end()){
            b.PB(a[i]);k++;
            ans=max(ans,p[i]+k);
            continue;
        }
        int pos=it-b.begin();
        b[pos]=a[i];
        ans=max(ans,p[i]+pos+1);
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 440 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 1884 KB Output is correct
2 Correct 57 ms 3908 KB Output is correct
3 Correct 61 ms 3912 KB Output is correct
4 Correct 59 ms 3932 KB Output is correct
5 Correct 65 ms 3792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 600 KB Output is correct
2 Correct 18 ms 1116 KB Output is correct
3 Correct 24 ms 1116 KB Output is correct
4 Correct 9 ms 1116 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 8 ms 1216 KB Output is correct
7 Correct 13 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1116 KB Output is correct
2 Correct 27 ms 1116 KB Output is correct
3 Correct 89 ms 1984 KB Output is correct
4 Correct 63 ms 2512 KB Output is correct
5 Correct 31 ms 1488 KB Output is correct
6 Correct 38 ms 2512 KB Output is correct
7 Correct 53 ms 2560 KB Output is correct
8 Correct 27 ms 1228 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 440 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 60 ms 1884 KB Output is correct
28 Correct 57 ms 3908 KB Output is correct
29 Correct 61 ms 3912 KB Output is correct
30 Correct 59 ms 3932 KB Output is correct
31 Correct 65 ms 3792 KB Output is correct
32 Correct 19 ms 600 KB Output is correct
33 Correct 18 ms 1116 KB Output is correct
34 Correct 24 ms 1116 KB Output is correct
35 Correct 9 ms 1116 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 8 ms 1216 KB Output is correct
38 Correct 13 ms 1116 KB Output is correct
39 Correct 27 ms 1116 KB Output is correct
40 Correct 27 ms 1116 KB Output is correct
41 Correct 89 ms 1984 KB Output is correct
42 Correct 63 ms 2512 KB Output is correct
43 Correct 31 ms 1488 KB Output is correct
44 Correct 38 ms 2512 KB Output is correct
45 Correct 53 ms 2560 KB Output is correct
46 Correct 27 ms 1228 KB Output is correct
47 Correct 28 ms 2136 KB Output is correct
48 Correct 28 ms 2140 KB Output is correct
49 Correct 60 ms 3912 KB Output is correct
50 Correct 38 ms 3652 KB Output is correct
51 Correct 28 ms 3020 KB Output is correct
52 Correct 39 ms 3776 KB Output is correct
53 Correct 32 ms 3788 KB Output is correct
54 Correct 45 ms 4404 KB Output is correct
55 Correct 53 ms 3956 KB Output is correct