Submission #1104160

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

const int N = 2e5 + 3;
int ar[N], neg[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], neg[i] = -ar[i];

  int res = 1;
  int dp[n+1];
  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:26:56: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |     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 42 ms 2640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1780 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 -