Submission #707124

#TimeUsernameProblemLanguageResultExecution timeMemory
7071243omda_FakeRabbit Carrot (LMIO19_triusis)C++14
0 / 100
2 ms340 KiB
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define ll long long
namespace __gnu_pbds{
          typedef tree<ll,
                       null_type,
                       less_equal<ll>,
                       rb_tree_tag,
                       tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;
#define ld long double
double eps=1e-9;
#define all(v) v.begin(),v.end()
#define fast cin.tie(0);cin.sync_with_stdio(0);
#define fs(n) fixed<<setprecision(n)
#define PI acos(-1.0)
#define inp(i,n,arr) for(int i=0;i<n;i++)cin>>arr[i];
#define clr(x,val) memset((x),(val),sizeof(x))
#define sz(x) (ll)x.size()
#define mp make_pair
#define debug(x) cout<<"[ "<<x<<" ]"<<endl;
#define debug2(x,y) cout<<"[ "<<x<<" ] "<<", [ "<<y<<" ]"<<endl;
#define debug3(x,y,z) cout<<"[ "<<x<<" ] "<<" , [ "<<y<<" ] "<<" , [ "<<z<<" ] "<<"\n";
void local(){
    fast;
   #ifndef ONLINE_JUDGE //                            ^_^
    freopen("input.txt", "r", stdin);
 
    freopen("output.txt", "w", stdout);
 
    #endif // ONLINE_JUDGE*/
}
int dx[] = {-1,0,1 ,0};
int dy[] = {0,-1,0 , 1};    
const ll oo=(ll)8e18;   
const ll mod=(ll)998244353;
//====================

void solution(){
   int n,m;cin>>n>>m;
   int cnt=0;
   int height=0;
   for(int i=0;i<n;i++){
        int num;cin>>num;
        if(num>height+m)
            cnt++,height+=m;
        else
            height=num;
   } 
   cout<<cnt;
}




int main(){
    local();
   int t=1,cnt=1;
  // cin>>t;
    while(t--){
        
        solution();
        cnt++;
    }
}

Compilation message (stderr)

triusis.cpp: In function 'void local()':
triusis.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...