Submission #1104162

# Submission time Handle Problem Language Result Execution time Memory
1104162 2024-10-23T04:07:48 Z vjudge1 Global Warming (CEOI18_glo) C++17
0 / 100
38 ms 2004 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 3;
int ar[N];

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, x; cin >> n >> x;
  for(int i=1; i<=n; ++i) cin >> ar[i];

  int res = 1;
  int dp[n+1];
  dp[0] = 0;
  vector<int> lis;
  for(int i=1; i<=n; ++i) {
    auto t = lower_bound(lis.begin(), lis.end(), ar[i]);
    if(t == lis.end()) lis.emplace_back(ar[i]);
    else *t = ar[i];
    dp[i] = lis.size();
  }

  res = lis.size();
  lis.clear();
  for(int i=n; i>=1; --i) {

    int x = lower_bound(lis.begin(), lis.end(), -ar[i] + x) - lis.begin();
    res = max(res, dp[i-1] + x);

    auto t = lower_bound(lis.begin(), lis.end(), -ar[i]);
    if(t == lis.end()) lis.emplace_back(-ar[i]);
    else *t = -ar[i];
  }

  cout << res << '\n';
  return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:27:56: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |     int x = lower_bound(lis.begin(), lis.end(), -ar[i] + x) - lis.begin();
      |                                                 ~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 2004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1012 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -