Submission #969585

# Submission time Handle Problem Language Result Execution time Memory
969585 2024-04-25T10:36:54 Z Spade1 Global Warming (CEOI18_glo) C++14
Compilation error
0 ms 0 KB
#pragma once
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pld> vpld;
typedef vector<vi> vvi;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define st first
#define nd second
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin(), (x).end()
#define ins insert

template<typename T> bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9 + 7;
const int INF = 0x3fffffff;
const ll LINF = 0x1fffffffffffffff;
const char nl = '\n';
const int MX = 2e5 + 3;

int a[MX], dp[MX];
vector<int> v1, v2;

void solve() {
  int n, x; cin >> n >> x;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    auto it = lower_bound(all(v1), a[i]);
    dp[i] = it-v1.begin()+1;
    if (it == v1.end()) v1.eb(a[i]);
    else *it = a[i];
  }
  int ans = 0;
  for (int i = n; i >= 1; --i) {
    auto it = lower_bound(all(v2), -a[i]);
    ckmax(ans, dp[i] + (int)(it-v2.begin()));
    a[i] += x;
    auto it = lower_bound(all(v2), -a[i]);
    if (it == v2.end()) v2.eb(a[i]);
    else *it = a[i];
  }
  cout << ans << nl;
}

int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0); cin.tie(NULL);
  int t = 1;
  // cin >> t;
  while (t--) { solve(); }
  return 0;
}

Compilation message

glo.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
glo.cpp: In function 'void solve()':
glo.cpp:63:10: error: conflicting declaration 'auto it'
   63 |     auto it = lower_bound(all(v2), -a[i]);
      |          ^~
glo.cpp:60:10: note: previous declaration as '__gnu_cxx::__normal_iterator<int*, std::vector<int> > it'
   60 |     auto it = lower_bound(all(v2), -a[i]);
      |          ^~