답안 #1084339

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1084339 2024-09-06T01:41:35 Z serpent_121 Global Warming (CEOI18_glo) C++17
100 / 100
78 ms 7668 KB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <numeric>
#include <cmath>
#include <cstring>
#include <climits>
#include <stack>
#include <bitset>
typedef long long ll;
using namespace std;

const ll MAXN = 2*1e5 + 5;
ll t[MAXN];
int main(){
    ll n,x; cin >> n >> x;
    for ( int i = 0; i<n; i++) cin >> t[i];
    vector<ll> s; ll lis = 0; ll dp[n];
    for (int i = n-1; i>=0; i--) {
        ll l=0; ll r = lis;
        while (l < r) {
            ll mid = (l+r)/2;
            if (s[mid]<=t[i]) r = mid;
            else l = mid+1;
        }
        if (r==lis) {s.push_back(t[i]);lis++;}
        else {
            s[r] = t[i];
        }
        dp[i] = r;
        
    }
    vector<ll> l; lis = 0; ll ans = 0;
    for (int i = 0; i<n; i++) {
        ll pos1 = lower_bound(l.begin(),l.end(),t[i]+x) - l.begin();
        ll pos = lower_bound(l.begin(),l.end(),t[i]) - l.begin();
        ans = max(ans, pos1 + dp[i] + 1);
        if (pos==lis) {
            lis++; l.push_back(t[i]);
        }
        else l[pos] = t[i];
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 412 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 348 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 1 ms 412 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 348 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 348 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 604 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 1 ms 412 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 348 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 348 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 604 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 348 KB Output is correct
20 Correct 1 ms 348 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 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 5448 KB Output is correct
2 Correct 72 ms 5456 KB Output is correct
3 Correct 78 ms 5460 KB Output is correct
4 Correct 71 ms 5308 KB Output is correct
5 Correct 44 ms 6860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1628 KB Output is correct
2 Correct 20 ms 1628 KB Output is correct
3 Correct 18 ms 1624 KB Output is correct
4 Correct 14 ms 2008 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 10 ms 2008 KB Output is correct
7 Correct 16 ms 1672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 2904 KB Output is correct
2 Correct 33 ms 2884 KB Output is correct
3 Correct 69 ms 5452 KB Output is correct
4 Correct 45 ms 6968 KB Output is correct
5 Correct 23 ms 3500 KB Output is correct
6 Correct 41 ms 6852 KB Output is correct
7 Correct 53 ms 7364 KB Output is correct
8 Correct 32 ms 2904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 412 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 348 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 348 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 604 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 348 KB Output is correct
20 Correct 1 ms 348 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 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 73 ms 5448 KB Output is correct
28 Correct 72 ms 5456 KB Output is correct
29 Correct 78 ms 5460 KB Output is correct
30 Correct 71 ms 5308 KB Output is correct
31 Correct 44 ms 6860 KB Output is correct
32 Correct 21 ms 1628 KB Output is correct
33 Correct 20 ms 1628 KB Output is correct
34 Correct 18 ms 1624 KB Output is correct
35 Correct 14 ms 2008 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 10 ms 2008 KB Output is correct
38 Correct 16 ms 1672 KB Output is correct
39 Correct 33 ms 2904 KB Output is correct
40 Correct 33 ms 2884 KB Output is correct
41 Correct 69 ms 5452 KB Output is correct
42 Correct 45 ms 6968 KB Output is correct
43 Correct 23 ms 3500 KB Output is correct
44 Correct 41 ms 6852 KB Output is correct
45 Correct 53 ms 7364 KB Output is correct
46 Correct 32 ms 2904 KB Output is correct
47 Correct 35 ms 2900 KB Output is correct
48 Correct 36 ms 2900 KB Output is correct
49 Correct 71 ms 5460 KB Output is correct
50 Correct 51 ms 7008 KB Output is correct
51 Correct 48 ms 5832 KB Output is correct
52 Correct 46 ms 7112 KB Output is correct
53 Correct 42 ms 7112 KB Output is correct
54 Correct 59 ms 7668 KB Output is correct
55 Correct 73 ms 5460 KB Output is correct