답안 #575461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
575461 2022-06-10T15:34:44 Z Huy Global Warming (CEOI18_glo) C++17
100 / 100
50 ms 10076 KB
#include<bits/stdc++.h>
#define int long long
#define pii pair<ll,ll>
#define fi first
#define se second

using namespace std;
using ll = long long;
using ldb = long double;
const int N = (int)5e5+2;
const int maxN = (int)5e5 + 5;
const int mod = 1e9 + 7;
const ll infty = 1e10;

void InputFile()
{
    //freopen("scrivener.inp","r",stdin);
    //freopen("scrivener.out","w",stdout);
    //freopen("test.out","r",stdin);
}

void FastInput()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

/// prove that optimal answer can be achieved by decrease a prefix

int n,x;
int dp[2][maxN];
int e[2][maxN];
int t[maxN];

void Read()
{
    cin >> n >> x;
    for(int i = 1;i <= n;i++)
    {
        cin >> t[i];
    }
    fill(e[0] + 1,e[0] + n + 1,infty);
    fill(e[1] + 1,e[1] + n + 1,infty);
    for(int i = 1;i <= n;i++)
    {
        dp[1][i] = lower_bound(e[1] + 1,e[1] + n + 1,t[i]) - e[1];
        e[1][dp[1][i]] = t[i];
        dp[0][i] = lower_bound(e[0] + 1,e[0] + n + 1,t[i] - x) - e[0];
        e[0][dp[0][i]] = t[i]-x;
        e[1][dp[0][i]] = min(e[1][dp[0][i]],t[i]-x);
    }
    cout << *max_element(dp[1] + 1,dp[1] + n + 1);
}

void Solve()
{

}

void Debug()
{
    //Main_sub();
    //Naive();
}


int32_t main()
{
    FastInput();
    //InputFile();
    //int sub_type;
    //cin >> sub_type;
    //Sieve();
    int test;
    //cin >> test;
    test = 1;
    while(test--)
        //for(int prc = 1; prc <= test; prc++)
    {
        Read();
        Solve();
        //Debug();
    }
}

/*
13 1
769 514 336 173 181 373 519 338 985 709 729 702 168
12 581
*/

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 8076 KB Output is correct
2 Correct 47 ms 10064 KB Output is correct
3 Correct 47 ms 10032 KB Output is correct
4 Correct 42 ms 10060 KB Output is correct
5 Correct 38 ms 9220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2292 KB Output is correct
2 Correct 10 ms 2228 KB Output is correct
3 Correct 13 ms 2260 KB Output is correct
4 Correct 11 ms 2324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 10 ms 2292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 4180 KB Output is correct
2 Correct 21 ms 4244 KB Output is correct
3 Correct 50 ms 8148 KB Output is correct
4 Correct 47 ms 9272 KB Output is correct
5 Correct 17 ms 4808 KB Output is correct
6 Correct 29 ms 8920 KB Output is correct
7 Correct 42 ms 9580 KB Output is correct
8 Correct 20 ms 5180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 45 ms 8076 KB Output is correct
28 Correct 47 ms 10064 KB Output is correct
29 Correct 47 ms 10032 KB Output is correct
30 Correct 42 ms 10060 KB Output is correct
31 Correct 38 ms 9220 KB Output is correct
32 Correct 10 ms 2292 KB Output is correct
33 Correct 10 ms 2228 KB Output is correct
34 Correct 13 ms 2260 KB Output is correct
35 Correct 11 ms 2324 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 9 ms 2260 KB Output is correct
38 Correct 10 ms 2292 KB Output is correct
39 Correct 21 ms 4180 KB Output is correct
40 Correct 21 ms 4244 KB Output is correct
41 Correct 50 ms 8148 KB Output is correct
42 Correct 47 ms 9272 KB Output is correct
43 Correct 17 ms 4808 KB Output is correct
44 Correct 29 ms 8920 KB Output is correct
45 Correct 42 ms 9580 KB Output is correct
46 Correct 20 ms 5180 KB Output is correct
47 Correct 20 ms 5196 KB Output is correct
48 Correct 21 ms 5164 KB Output is correct
49 Correct 49 ms 10008 KB Output is correct
50 Correct 38 ms 9240 KB Output is correct
51 Correct 27 ms 7024 KB Output is correct
52 Correct 35 ms 9380 KB Output is correct
53 Correct 38 ms 9388 KB Output is correct
54 Correct 39 ms 10076 KB Output is correct
55 Correct 38 ms 10036 KB Output is correct