Submission #1327410

#TimeUsernameProblemLanguageResultExecution timeMemory
1327410ilovewaguriRabbit Carrot (LMIO19_triusis)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#define NAME "TEST"
#define nl '\n'
#define allofa(x,sz) x+1,x+sz+1
#define allof(x) x.begin(),x.end()
#define mset(x,val) memset(x,val,sizeof(x))
template<typename T> T Max(T x, T y){return(x>y)?x:y;};
template<typename T> T Min(T x, T y){return(x<y)?x:y;};
template<class X,class Y> bool minimize(X &a, Y b){if(a>b){a=b;return true;}return false;};
template<class X,class Y> bool maximize(X &a, Y b){if(a<b){a=b;return true;}return false;};
typedef long long ll;
const ll mod = (long long)1e9+7;
const ll LINF = (long long)1e18;
const int INF = (int)1e9;
const int MAXN = (int)2e5+5;
int a[MAXN];
int n,M;

void ccps() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    if(fopen(NAME".inp","r")) {
        freopen(NAME".inp","r",stdin);
        freopen(NAME".out","w",stdout);
    }
}

signed main() {
    ccps();
    cin >> n >> M;
    for (int i = 1; i<=n; i++) {
        cin >> a[i];
    }
    b.push_back(0);
    for (int i = 1; i<=n; i++) {
        if(a[i]<a[i-1]) b.push_back(a[i]);
        else if(a[i]-a[i-1]<=M) b.push_back(a[i]);
    }
    int m = (int)b.size()-1;
    cout << n-m;
}

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:35:5: error: 'b' was not declared in this scope
   35 |     b.push_back(0);
      |     ^
triusis.cpp: In function 'void ccps()':
triusis.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(NAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen(NAME".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~