Submission #1072365

# Submission time Handle Problem Language Result Execution time Memory
1072365 2024-08-23T17:33:11 Z ventusliberum Global Warming (CEOI18_glo) C++17
100 / 100
50 ms 4700 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(n, inf), f(n);
  int ans = 0;
  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();
    lis[j] = t[i] - x;
  }
  lis.assign(n, inf);
  rrep(i, n) {
    int j = lower_bound(all(lis), -t[i]) - lis.begin();
    chmax(ans, f[i] + j + 1);
    lis[j] = -t[i];
  }
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 452 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 348 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
# Verdict Execution time Memory Grader output
1 Correct 1 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 452 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 348 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 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 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 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 452 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 348 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 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 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 460 KB Output is correct
19 Correct 1 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 1 ms 604 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 3924 KB Output is correct
2 Correct 40 ms 4560 KB Output is correct
3 Correct 41 ms 4692 KB Output is correct
4 Correct 50 ms 4552 KB Output is correct
5 Correct 28 ms 3932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1368 KB Output is correct
2 Correct 11 ms 1372 KB Output is correct
3 Correct 9 ms 1288 KB Output is correct
4 Correct 7 ms 1112 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 9 ms 1208 KB Output is correct
7 Correct 8 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2412 KB Output is correct
2 Correct 17 ms 2608 KB Output is correct
3 Correct 35 ms 4696 KB Output is correct
4 Correct 38 ms 3932 KB Output is correct
5 Correct 15 ms 2136 KB Output is correct
6 Correct 25 ms 3676 KB Output is correct
7 Correct 29 ms 4524 KB Output is correct
8 Correct 15 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 452 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 348 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 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 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 460 KB Output is correct
19 Correct 1 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 1 ms 604 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 39 ms 3924 KB Output is correct
28 Correct 40 ms 4560 KB Output is correct
29 Correct 41 ms 4692 KB Output is correct
30 Correct 50 ms 4552 KB Output is correct
31 Correct 28 ms 3932 KB Output is correct
32 Correct 10 ms 1368 KB Output is correct
33 Correct 11 ms 1372 KB Output is correct
34 Correct 9 ms 1288 KB Output is correct
35 Correct 7 ms 1112 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 9 ms 1208 KB Output is correct
38 Correct 8 ms 1372 KB Output is correct
39 Correct 18 ms 2412 KB Output is correct
40 Correct 17 ms 2608 KB Output is correct
41 Correct 35 ms 4696 KB Output is correct
42 Correct 38 ms 3932 KB Output is correct
43 Correct 15 ms 2136 KB Output is correct
44 Correct 25 ms 3676 KB Output is correct
45 Correct 29 ms 4524 KB Output is correct
46 Correct 15 ms 2396 KB Output is correct
47 Correct 18 ms 2396 KB Output is correct
48 Correct 23 ms 2396 KB Output is correct
49 Correct 38 ms 4564 KB Output is correct
50 Correct 27 ms 3804 KB Output is correct
51 Correct 25 ms 2908 KB Output is correct
52 Correct 29 ms 3928 KB Output is correct
53 Correct 25 ms 3932 KB Output is correct
54 Correct 27 ms 4700 KB Output is correct
55 Correct 32 ms 4700 KB Output is correct