#include "elephants.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
//#define int long long
#define pb push_back
#define s second
#define f first
#define pf push_front
#define inf 100000000000000000
#define bitebi __builtin_popcountll
#define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
#define YES cout <<"YES\n"
#define NO cout << "NO\n"
#define debug cout << "Here Fine" << endl ;
#define pr pair < int , int >
#define fbo find_by_order // returns iterator
#define ook order_of_key // returns strictly less numbers than key
using namespace std ;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const double Pi=acos(-1.0);
const double EPS=1E-8;
const int mod = 1000000007 ;
const int mod1 = 998244353 ;
const int NN = 285000 ;
mt19937 R(time(0));
map < int , int > ma , ma1 ;
//int node[ 200 ][ 4 * NN ] ;
int n , l ;
vector < pair < int , int > > v ;
int pos[ NN ] ;
void init(int N, int L, int X[]){
n = N , l = L ;
FOR( i , N ){
v.pb( { X[ i ] , i } ) ;
pos[ i ] = i ;
}
}
int update(int i, int y){
int ps = pos[ i ] ;
if( v[ ps ].f < y ){
int j = ps ;
while( true ){
if( j == n - 1 ){
v[ j ].f = y ;
pos[ v[ j ].s ] = j ;
break ;
}
if( v[ j + 1 ].f >= y ){
v[ j ].f = y ;
pos[ v[ j ].s ] = j ;
break ;
}
pos[ v[ j + 1 ].s ] = j ;
swap( v[ j ] , v[ j + 1 ] ) ;
j ++ ;
}
}
else{
int j = ps ;
while( true ){
if( j == 0 ){
v[ j ].f = y ;
pos[ v[ j ].s ] = j ;
break ;
}
if( v[ j - 1 ].f <= y ){
v[ j ].f = y ;
pos[ v[ j ].s ] = j ;
break ;
}
pos[ v[ j - 1 ].s ] = j ;
swap( v[ j ] , v[ j - 1 ] ) ;
j -- ;
}
}
int ans = 0 ;
int lst = -1 ;
FOR( i , n ){
if( lst >= v[ i ].f ) continue ;
ans ++ ;
lst = v[ i ].f + l ;
}
return ans ;
}
//#define MAX_N 1000000
//#define MAX_M 1000000
//
//static int N,L,M;
//static int X[MAX_N];
//static int ii[MAX_M];
//static int yy[MAX_M];
//
//void read_input()
//{
// int i;
// scanf("%d %d %d",&N,&L,&M);
// for(i=0; i<N; i++)
// scanf("%d",&X[i]);
// for(i=0; i<M; i++)
// scanf("%d %d",&ii[i],&yy[i]);
//}
//
//int main()
//{
// int i, ans;
//
// read_input();
// init(N,L,X);
// for(i=0; i<M; i++) {
// ans = update(ii[i],yy[i]);
// printf("%d\n", ans);
// }
// return 0;
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1018 ms |
2140 KB |
Output is correct |
8 |
Correct |
1988 ms |
2388 KB |
Output is correct |
9 |
Correct |
1475 ms |
3400 KB |
Output is correct |
10 |
Correct |
7850 ms |
3144 KB |
Output is correct |
11 |
Correct |
8167 ms |
3152 KB |
Output is correct |
12 |
Correct |
7544 ms |
3272 KB |
Output is correct |
13 |
Correct |
8004 ms |
2888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1018 ms |
2140 KB |
Output is correct |
8 |
Correct |
1988 ms |
2388 KB |
Output is correct |
9 |
Correct |
1475 ms |
3400 KB |
Output is correct |
10 |
Correct |
7850 ms |
3144 KB |
Output is correct |
11 |
Correct |
8167 ms |
3152 KB |
Output is correct |
12 |
Correct |
7544 ms |
3272 KB |
Output is correct |
13 |
Correct |
8004 ms |
2888 KB |
Output is correct |
14 |
Correct |
1907 ms |
3156 KB |
Output is correct |
15 |
Correct |
4174 ms |
3084 KB |
Output is correct |
16 |
Execution timed out |
9024 ms |
3876 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1018 ms |
2140 KB |
Output is correct |
8 |
Correct |
1988 ms |
2388 KB |
Output is correct |
9 |
Correct |
1475 ms |
3400 KB |
Output is correct |
10 |
Correct |
7850 ms |
3144 KB |
Output is correct |
11 |
Correct |
8167 ms |
3152 KB |
Output is correct |
12 |
Correct |
7544 ms |
3272 KB |
Output is correct |
13 |
Correct |
8004 ms |
2888 KB |
Output is correct |
14 |
Correct |
1907 ms |
3156 KB |
Output is correct |
15 |
Correct |
4174 ms |
3084 KB |
Output is correct |
16 |
Execution timed out |
9024 ms |
3876 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |