#include "elephants.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
const int mxn=2e5+5,MAX=1e9+5;
int n,k,arr[mxn];
void init(int N, int L, int X[])
{
n=N,k=L;
for(int i=1;i<=n;i++){
arr[i]=X[i-1]+1;
}
}
int update(int i, int y)
{
i++,y++;
arr[i]=y;
if(arr[i]<arr[i-1]){
int idx=i;
while(idx>1&&arr[idx]<arr[idx-1]){
swap(arr[idx],arr[idx-1]);
idx--;
}
}
else{
int idx=i;
while(idx<n&&arr[idx]>arr[idx+1]){
swap(arr[idx],arr[idx+1]);
idx++;
}
}
int ans=1;
int left=arr[1];
for(int i=2;i<=n;i++){
if(arr[i]-left>k){
ans++;
left=arr[i];
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |