답안 #1072353

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072353 2024-08-23T17:24:58 Z ventusliberum Global Warming (CEOI18_glo) C++17
100 / 100
39 ms 4576 KB
/**
 *    title:  Global Warming
**/
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define si(x) int(x.size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
template <class T, class U> inline bool chmax(T &a, U b) { return (a < b ? a = b, 1 : 0); }
template <class T, class U> inline bool chmin(T &a, U b) { return (b < a ? a = b, 1 : 0); }
template <class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, si(v)) os << (i ? " " : "") << v[i]; return os; }
using ll = long long;
constexpr int inf = 1001001001;
constexpr long long infll = 4004004004004004004LL;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, x;
  cin >> n >> x;
  vector<int> t(n);
  cin >> t;
  vector<int> lis, f(n);
  rep(i, n) {
    int j = lower_bound(all(lis), t[i]) - lis.begin();
    f[i] = j;
    j = lower_bound(all(lis), t[i] - x) - lis.begin();
    if (j == si(lis)) lis.resize(j + 1);
    lis[j] = t[i] - x;
  }
  int ans = si(lis);
  lis.clear();
  for (int i = n - 1; i > 0; i--) {
    int j = lower_bound(all(lis), -t[i]) - lis.begin();
    chmax(ans, f[i] + j + 1);
    if (j == si(lis)) lis.resize(j + 1);
    lis[j] = -t[i];
  }
  cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 3932 KB Output is correct
2 Correct 35 ms 3920 KB Output is correct
3 Correct 39 ms 3932 KB Output is correct
4 Correct 35 ms 3932 KB Output is correct
5 Correct 19 ms 3808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1372 KB Output is correct
2 Correct 9 ms 1112 KB Output is correct
3 Correct 8 ms 1348 KB Output is correct
4 Correct 5 ms 1216 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1284 KB Output is correct
7 Correct 7 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 2136 KB Output is correct
2 Correct 19 ms 2224 KB Output is correct
3 Correct 34 ms 3796 KB Output is correct
4 Correct 20 ms 3804 KB Output is correct
5 Correct 10 ms 2392 KB Output is correct
6 Correct 23 ms 3668 KB Output is correct
7 Correct 21 ms 4320 KB Output is correct
8 Correct 13 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 35 ms 3932 KB Output is correct
28 Correct 35 ms 3920 KB Output is correct
29 Correct 39 ms 3932 KB Output is correct
30 Correct 35 ms 3932 KB Output is correct
31 Correct 19 ms 3808 KB Output is correct
32 Correct 10 ms 1372 KB Output is correct
33 Correct 9 ms 1112 KB Output is correct
34 Correct 8 ms 1348 KB Output is correct
35 Correct 5 ms 1216 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 5 ms 1284 KB Output is correct
38 Correct 7 ms 1112 KB Output is correct
39 Correct 17 ms 2136 KB Output is correct
40 Correct 19 ms 2224 KB Output is correct
41 Correct 34 ms 3796 KB Output is correct
42 Correct 20 ms 3804 KB Output is correct
43 Correct 10 ms 2392 KB Output is correct
44 Correct 23 ms 3668 KB Output is correct
45 Correct 21 ms 4320 KB Output is correct
46 Correct 13 ms 2140 KB Output is correct
47 Correct 17 ms 2140 KB Output is correct
48 Correct 18 ms 1996 KB Output is correct
49 Correct 37 ms 3928 KB Output is correct
50 Correct 19 ms 3808 KB Output is correct
51 Correct 17 ms 3040 KB Output is correct
52 Correct 19 ms 3920 KB Output is correct
53 Correct 18 ms 3924 KB Output is correct
54 Correct 20 ms 4576 KB Output is correct
55 Correct 29 ms 4140 KB Output is correct