Submission #1104183

# Submission time Handle Problem Language Result Execution time Memory
1104183 2024-10-23T06:29:13 Z vjudge1 Wall (IOI14_wall) C++17
Compilation error
0 ms 0 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, g; cin >> n >> g;
  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]);
    dp[i] = t - lis.begin() + 1;

    if(t == lis.end()) lis.emplace_back(ar[i]);
    else *t = ar[i];

    //cout << dp[i] << " \n"[i == n]; 
  }

  res = lis.size();
  lis.clear();
  for(int i=n; i>=1; --i) {
    int x = lower_bound(lis.begin(), lis.end(), -ar[i] + 2*g) - lis.begin();

    //cout << "I: " << i << " => ";
    //for(auto x : lis) cout << x << ' ';
    //cout << " | " << x << endl;
    res = max(res, dp[i] + x );

    int y = lower_bound(lis.begin(), lis.end(), -ar[i] + g) - lis.begin();
    if(y == lis.size()) lis.emplace_back(-ar[i] + g);
    else lis[y] = -ar[i] + g;
  }

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

Compilation message

wall.cpp: In function 'int main()':
wall.cpp:37:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     if(y == lis.size()) lis.emplace_back(-ar[i] + g);
      |        ~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc3hzzzn.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccttRDPm.o:wall.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc3hzzzn.o: in function `main':
grader.cpp:(.text.startup+0x133): undefined reference to `buildWall(int, int, int*, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status