답안 #571232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
571232 2022-06-01T15:18:29 Z YouAreMyGalaxy Global Warming (CEOI18_glo) C++17
100 / 100
48 ms 3796 KB
//Make CSP great again
//Vengeance
#include <bits/stdc++.h>
#define TASK "TESTCODE"
#define Log2(x) 31 - __builtin_clz(x)
using namespace std;
const int N = 2e5;
int dp[2][N + 1], n, x;
int res = 0;
void read()
{
    cin >> n >> x;
    for (int i = 1; i <= n; ++ i)
    {
        int a;
        cin >> a;
        dp[0][i] = dp[1][i] = INT_MAX;
        int j = lower_bound(dp[1] + 1, dp[1] + i + 1, a) - dp[1];
        dp[1][j] = a;
        res = max(res, j);
        j = lower_bound(dp[0] + 1, dp[0] + i + 1, a - x) - dp[0];
        dp[0][j] = a - x;
        dp[1][j] = min(dp[1][j], dp[0][j]);
    }
    cout << res;
}
void solve()
{
 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (fopen(TASK".INP", "r"))
    {
        freopen(TASK".INP", "r", stdin);
        //freopen(TASK".OUT", "w", stdout);
    }
    int t = 1;
    bool typetest = false;
    if (typetest)
    {
        cin >> t;
    }
    for (int __ = 1; __ <= t; ++ __)
    {
        //cout << "Case " << __ << ": ";
        read();
        solve();
    }
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 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 212 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 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 212 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 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 212 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 328 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 1 ms 332 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 41 ms 3696 KB Output is correct
2 Correct 42 ms 3788 KB Output is correct
3 Correct 48 ms 3716 KB Output is correct
4 Correct 44 ms 3784 KB Output is correct
5 Correct 24 ms 3016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1092 KB Output is correct
2 Correct 9 ms 1172 KB Output is correct
3 Correct 13 ms 1112 KB Output is correct
4 Correct 9 ms 944 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 7 ms 896 KB Output is correct
7 Correct 9 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1980 KB Output is correct
2 Correct 21 ms 2004 KB Output is correct
3 Correct 42 ms 3796 KB Output is correct
4 Correct 28 ms 3020 KB Output is correct
5 Correct 12 ms 1692 KB Output is correct
6 Correct 24 ms 3000 KB Output is correct
7 Correct 31 ms 3604 KB Output is correct
8 Correct 19 ms 1996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 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 212 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 328 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 1 ms 332 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 41 ms 3696 KB Output is correct
28 Correct 42 ms 3788 KB Output is correct
29 Correct 48 ms 3716 KB Output is correct
30 Correct 44 ms 3784 KB Output is correct
31 Correct 24 ms 3016 KB Output is correct
32 Correct 9 ms 1092 KB Output is correct
33 Correct 9 ms 1172 KB Output is correct
34 Correct 13 ms 1112 KB Output is correct
35 Correct 9 ms 944 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 7 ms 896 KB Output is correct
38 Correct 9 ms 1108 KB Output is correct
39 Correct 21 ms 1980 KB Output is correct
40 Correct 21 ms 2004 KB Output is correct
41 Correct 42 ms 3796 KB Output is correct
42 Correct 28 ms 3020 KB Output is correct
43 Correct 12 ms 1692 KB Output is correct
44 Correct 24 ms 3000 KB Output is correct
45 Correct 31 ms 3604 KB Output is correct
46 Correct 19 ms 1996 KB Output is correct
47 Correct 21 ms 2016 KB Output is correct
48 Correct 25 ms 1988 KB Output is correct
49 Correct 42 ms 3768 KB Output is correct
50 Correct 25 ms 2984 KB Output is correct
51 Correct 22 ms 2260 KB Output is correct
52 Correct 25 ms 3020 KB Output is correct
53 Correct 29 ms 3140 KB Output is correct
54 Correct 30 ms 3796 KB Output is correct
55 Correct 41 ms 3740 KB Output is correct