답안 #397952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397952 2021-05-03T12:27:41 Z Victor Global Warming (CEOI18_glo) C++17
100 / 100
70 ms 6152 KB
#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = b - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)

#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back

#define umap unordered_map
#define uset unordered_set

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;

const int INF = 1000000007;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);

    int n, x, ans = 0, temps[200001], pos[200001], val[200001];
    cin >> n >> x;
    vi subseq(n), revseq;
    revseq = subseq;

    rep(i, 0, n) cin >> temps[i];

    int longest = 0, revlong = 0;

    per(i, 0, n) {
        int temp = -temps[i];

        int idx = lower_bound(revseq.begin(), revseq.begin() + revlong, temp) - revseq.begin();

        pos[i] = idx;
        val[i] = revseq[idx];

        revseq[idx] = temp;
        if (idx == revlong) ++revlong;
    }
    
    ans = revlong;
    rep(i, 0, n) {
        int temp = temps[i] - x;

        int idx = lower_bound(subseq.begin(), subseq.begin() + longest, temp) - subseq.begin();
        subseq[idx] = temp;
        if (idx == longest) ++longest;

        revseq[pos[i]] = val[i];
        if (!val[i]) --revlong;

        temp = -temp;
        int revidx = lower_bound(revseq.begin(), revseq.begin() + revlong, temp) - revseq.begin();

        ans=max(ans,idx+revidx+1);
    }

    cout << ans << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 6152 KB Output is correct
2 Correct 61 ms 6128 KB Output is correct
3 Correct 64 ms 6104 KB Output is correct
4 Correct 70 ms 6140 KB Output is correct
5 Correct 35 ms 5324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1740 KB Output is correct
2 Correct 17 ms 1780 KB Output is correct
3 Correct 15 ms 1788 KB Output is correct
4 Correct 9 ms 1612 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 8 ms 1484 KB Output is correct
7 Correct 15 ms 1708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 3148 KB Output is correct
2 Correct 26 ms 3248 KB Output is correct
3 Correct 59 ms 6124 KB Output is correct
4 Correct 36 ms 5384 KB Output is correct
5 Correct 17 ms 2784 KB Output is correct
6 Correct 28 ms 5144 KB Output is correct
7 Correct 35 ms 5892 KB Output is correct
8 Correct 24 ms 3276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 62 ms 6152 KB Output is correct
28 Correct 61 ms 6128 KB Output is correct
29 Correct 64 ms 6104 KB Output is correct
30 Correct 70 ms 6140 KB Output is correct
31 Correct 35 ms 5324 KB Output is correct
32 Correct 16 ms 1740 KB Output is correct
33 Correct 17 ms 1780 KB Output is correct
34 Correct 15 ms 1788 KB Output is correct
35 Correct 9 ms 1612 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 8 ms 1484 KB Output is correct
38 Correct 15 ms 1708 KB Output is correct
39 Correct 26 ms 3148 KB Output is correct
40 Correct 26 ms 3248 KB Output is correct
41 Correct 59 ms 6124 KB Output is correct
42 Correct 36 ms 5384 KB Output is correct
43 Correct 17 ms 2784 KB Output is correct
44 Correct 28 ms 5144 KB Output is correct
45 Correct 35 ms 5892 KB Output is correct
46 Correct 24 ms 3276 KB Output is correct
47 Correct 30 ms 3240 KB Output is correct
48 Correct 31 ms 3236 KB Output is correct
49 Correct 65 ms 6148 KB Output is correct
50 Correct 34 ms 5356 KB Output is correct
51 Correct 34 ms 4100 KB Output is correct
52 Correct 34 ms 5488 KB Output is correct
53 Correct 30 ms 5372 KB Output is correct
54 Correct 36 ms 6100 KB Output is correct
55 Correct 52 ms 6084 KB Output is correct