# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
371001 | 2021-02-25T12:26:20 Z | ntabc05101 | Global Warming (CEOI18_glo) | C++14 | 71 ms | 5232 KB |
#ifndef LOCAL #define NDEBUG 1 #endif // LOCAL #include<bits/stdc++.h> #define taskname "" #define i64_ int64_t int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } else if (fopen(taskname".in", "r")) { freopen(taskname".in", "r", stdin); freopen(taskname".out", "w", stdout); } std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n, x; std::cin>>n>>x; i64_ a[n]; for (int i=0; i<n; ++i) std::cin>>a[i]; int result=0; std::vector<int> lis; int dp[n]; for (int i=0; i<n; ++i) { int pos=std::lower_bound(begin(lis), end(lis), a[i])-begin(lis); if (pos==lis.size()) lis.emplace_back(a[i]); else lis[pos]=a[i]; dp[i]=1+pos; result=std::max(result, dp[i]); } lis.clear(); for (int i=n-1; i>=0; --i) { int pos=std::lower_bound(begin(lis), end(lis), -a[i])-begin(lis); int j=std::lower_bound(begin(lis), end(lis), -a[i]+x)-begin(lis); if (pos==lis.size()) lis.emplace_back(-a[i]); else lis[pos]=-a[i]; result=std::max(result, dp[i]+j); } std::cout<<result<<"\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 71 ms | 4588 KB | Output is correct |
2 | Correct | 60 ms | 4588 KB | Output is correct |
3 | Correct | 61 ms | 4588 KB | Output is correct |
4 | Correct | 61 ms | 4688 KB | Output is correct |
5 | Correct | 33 ms | 4460 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 1388 KB | Output is correct |
2 | Correct | 14 ms | 1388 KB | Output is correct |
3 | Correct | 14 ms | 1388 KB | Output is correct |
4 | Correct | 8 ms | 1516 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 8 ms | 1516 KB | Output is correct |
7 | Correct | 12 ms | 1388 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 2540 KB | Output is correct |
2 | Correct | 26 ms | 2540 KB | Output is correct |
3 | Correct | 52 ms | 4716 KB | Output is correct |
4 | Correct | 34 ms | 4332 KB | Output is correct |
5 | Correct | 16 ms | 2416 KB | Output is correct |
6 | Correct | 28 ms | 4332 KB | Output is correct |
7 | Correct | 35 ms | 4976 KB | Output is correct |
8 | Correct | 22 ms | 2540 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 71 ms | 4588 KB | Output is correct |
28 | Correct | 60 ms | 4588 KB | Output is correct |
29 | Correct | 61 ms | 4588 KB | Output is correct |
30 | Correct | 61 ms | 4688 KB | Output is correct |
31 | Correct | 33 ms | 4460 KB | Output is correct |
32 | Correct | 15 ms | 1388 KB | Output is correct |
33 | Correct | 14 ms | 1388 KB | Output is correct |
34 | Correct | 14 ms | 1388 KB | Output is correct |
35 | Correct | 8 ms | 1516 KB | Output is correct |
36 | Correct | 1 ms | 364 KB | Output is correct |
37 | Correct | 8 ms | 1516 KB | Output is correct |
38 | Correct | 12 ms | 1388 KB | Output is correct |
39 | Correct | 26 ms | 2540 KB | Output is correct |
40 | Correct | 26 ms | 2540 KB | Output is correct |
41 | Correct | 52 ms | 4716 KB | Output is correct |
42 | Correct | 34 ms | 4332 KB | Output is correct |
43 | Correct | 16 ms | 2416 KB | Output is correct |
44 | Correct | 28 ms | 4332 KB | Output is correct |
45 | Correct | 35 ms | 4976 KB | Output is correct |
46 | Correct | 22 ms | 2540 KB | Output is correct |
47 | Correct | 29 ms | 2540 KB | Output is correct |
48 | Correct | 33 ms | 2540 KB | Output is correct |
49 | Correct | 70 ms | 4588 KB | Output is correct |
50 | Correct | 34 ms | 4340 KB | Output is correct |
51 | Correct | 35 ms | 3440 KB | Output is correct |
52 | Correct | 33 ms | 4460 KB | Output is correct |
53 | Correct | 29 ms | 4460 KB | Output is correct |
54 | Correct | 37 ms | 5232 KB | Output is correct |
55 | Correct | 50 ms | 4716 KB | Output is correct |