Submission #777394

#TimeUsernameProblemLanguageResultExecution timeMemory
777394lollipopDancing Elephants (IOI11_elephants)C++17
50 / 100
9024 ms3876 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...