Submission #393795

# Submission time Handle Problem Language Result Execution time Memory
393795 2021-04-24T13:29:29 Z Qw3rTy Rabbit Carrot (LMIO19_triusis) C++11
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
using namespace std;

const int maxN = 2e5+5;

int f[maxN];
int a[maxN];
int N,M;

void testIO(){
    freopen("../test.in","r",stdin);
    return;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //testIO();
    cin >> N >> M;
    for(int i = 1; i <= N; ++i)cin >> a[i];
    for(int i = 1; i <= N; ++i){
        if(a[i] <= a[i-1] + M)f[i] = f[i-1];
        else{
            int cnt = 0;
            while(a[i]-M*cnt > a[i-cnt-1])++cnt;
            f[i] = f[i-1] + cnt;
        }
    }
    cout << f[N] << '\n';
    return 0;
}

Compilation message

triusis.cpp: In function 'void testIO()':
triusis.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   11 |     freopen("../test.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -