Submission #1254604

#TimeUsernameProblemLanguageResultExecution timeMemory
1254604snairsRabbit Carrot (LMIO19_triusis)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void setIO(string name = "") {
	cin.tie(0)->sync_with_stdio(0);
	if ((int)name.size()) {
		freopen((name + ".in").c_str(), "r", stdin);
		freopen((name + ".out").c_str(), "w", stdout);
	}
}
int poles(vector<ll> const& a, ll m)
{
    int n = a.size();
    const int INF = 1e9;
    vector<ll> d(n+1, INF);
    d[0] = -INF;
    for (int i = 0; i < n; i++)
    {
        int l = upper_bound(d.begin(), d.end(), a[i]-m) - d.begin();
        if (d[l-1] <= a[i] && a[i] <= d[l])
            d[l] = a[i];
    }
    int ans = 0;
    for (int l = 0; l <= n; l++)
    {
        if (d[l] < INF) ans = l;
    }
    return ans;
}
int main() {
    setIO();
    ll n,m;
    cin >> n >> m;
    vector <int> height(n+1);
    height[0]=0;
    for(int i=0;i<n;i++) cin >> height[i+1];
    cout << poles(height,m)-1;
    
    
}

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:37:19: error: invalid initialization of reference of type 'const std::vector<long long int>&' from expression of type 'std::vector<int>'
   37 |     cout << poles(height,m)-1;
      |                   ^~~~~~
triusis.cpp:11:29: note: in passing argument 1 of 'int poles(const std::vector<long long int>&, ll)'
   11 | int poles(vector<ll> const& a, ll m)
      |           ~~~~~~~~~~~~~~~~~~^
triusis.cpp: In function 'void setIO(std::string)':
triusis.cpp:7:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |                 freopen((name + ".in").c_str(), "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:8:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |                 freopen((name + ".out").c_str(), "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~