Submission #894501

# Submission time Handle Problem Language Result Execution time Memory
894501 2023-12-28T11:18:18 Z vjudge1 The short shank; Redemption (BOI21_prison) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 5e5;

int n, d, t, a[N], b[N];
vector<int> add[N], rem[N];

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n >> d >> t;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > t) continue;
    
    add[i].push_back(i);
    rem[min(n, i + t-a[i] + 1)].push_back(i);
  }
  
  int ans = 0;
  set<int> st;
  for (int i = 0; i < n; i++) {
    for (int& j : add[i]) st.insert(j);
    for (int& j : rem[i]) st.erase(j);

    if (a[i] <= t) {
      b[i] = -1;
      continue;
    }

    if (st.empty()) {
      b[i] = -1;
      ans++;
    }
    else b[i] = *prev(st.end());
  }

  int mx = 0;
  st.clear();
  for (int i = n-1; i >= 0; i--) {
    while (!st.empty() && *prev(st.end()) > i) {
      st.erase(st.end());
    }

    mx = max(mx, st.size());

    if (b[i] != -1) st.insert(b[i]);
  }

  cout << n - ans - mx << "\n";
}

Compilation message

prison.cpp: In function 'int main()':
prison.cpp:46:27: error: no matching function for call to 'max(int&, std::set<int>::size_type)'
   46 |     mx = max(mx, st.size());
      |                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from prison.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
prison.cpp:46:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::set<int>::size_type' {aka 'long unsigned int'})
   46 |     mx = max(mx, st.size());
      |                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from prison.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
prison.cpp:46:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::set<int>::size_type' {aka 'long unsigned int'})
   46 |     mx = max(mx, st.size());
      |                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from prison.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
prison.cpp:46:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   46 |     mx = max(mx, st.size());
      |                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from prison.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
prison.cpp:46:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   46 |     mx = max(mx, st.size());
      |                           ^