답안 #574361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
574361 2022-06-08T12:25:31 Z Tien_Noob Global Warming (CEOI18_glo) C++17
100 / 100
47 ms 3148 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 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 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 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 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 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 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 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 2636 KB Output is correct
2 Correct 40 ms 3088 KB Output is correct
3 Correct 45 ms 3116 KB Output is correct
4 Correct 39 ms 3148 KB Output is correct
5 Correct 24 ms 2988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1108 KB Output is correct
2 Correct 10 ms 1092 KB Output is correct
3 Correct 10 ms 1100 KB Output is correct
4 Correct 8 ms 980 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 980 KB Output is correct
7 Correct 8 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1860 KB Output is correct
2 Correct 20 ms 1996 KB Output is correct
3 Correct 47 ms 3136 KB Output is correct
4 Correct 23 ms 2996 KB Output is correct
5 Correct 12 ms 1620 KB Output is correct
6 Correct 23 ms 2980 KB Output is correct
7 Correct 29 ms 3060 KB Output is correct
8 Correct 18 ms 2012 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 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 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 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 37 ms 2636 KB Output is correct
28 Correct 40 ms 3088 KB Output is correct
29 Correct 45 ms 3116 KB Output is correct
30 Correct 39 ms 3148 KB Output is correct
31 Correct 24 ms 2988 KB Output is correct
32 Correct 12 ms 1108 KB Output is correct
33 Correct 10 ms 1092 KB Output is correct
34 Correct 10 ms 1100 KB Output is correct
35 Correct 8 ms 980 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 7 ms 980 KB Output is correct
38 Correct 8 ms 1116 KB Output is correct
39 Correct 20 ms 1860 KB Output is correct
40 Correct 20 ms 1996 KB Output is correct
41 Correct 47 ms 3136 KB Output is correct
42 Correct 23 ms 2996 KB Output is correct
43 Correct 12 ms 1620 KB Output is correct
44 Correct 23 ms 2980 KB Output is correct
45 Correct 29 ms 3060 KB Output is correct
46 Correct 18 ms 2012 KB Output is correct
47 Correct 19 ms 1992 KB Output is correct
48 Correct 18 ms 2000 KB Output is correct
49 Correct 41 ms 3128 KB Output is correct
50 Correct 25 ms 2952 KB Output is correct
51 Correct 18 ms 2272 KB Output is correct
52 Correct 24 ms 3080 KB Output is correct
53 Correct 24 ms 3020 KB Output is correct
54 Correct 30 ms 3072 KB Output is correct
55 Correct 34 ms 3104 KB Output is correct