Submission #348642

#TimeUsernameProblemLanguageResultExecution timeMemory
348642talant117408Dancing Elephants (IOI11_elephants)C++17
26 / 100
9073 ms3948 KiB
#include "elephants.h" #ifndef EVAL #include "grader.cpp" #endif #pragma GCC optimize("Ofast") #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //using namespace __gnu_pbds; using namespace std; //typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; #define precision(n) fixed << setprecision(n) #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define eps (double)1e-9 #define PI 2*acos(0.0) #define endl "\n" #define sz(v) int((v).size()) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define OK cout << "OK" << endl; int n; int len, pos[50003]; vector <int> ls; set <int> st; void init(int N, int L, int X[]){ n = N; if(n > 70000) exit(0); len = L; for(int i = 0; i < n; i++) pos[i] = X[i]; for(int i = 0; i < n; i++) st.insert(pos[i]); for(auto to : st){ if(sz(ls) == 0 || ls.back()+len < to) ls.pb(to); } } int update(int i, int y){ int prev = pos[i]; st.erase(st.find(pos[i])); pos[i] = y; st.insert(pos[i]); auto it = st.lb(min(y, prev)); while(sz(ls) && ls.back() >= min(y, prev)) ls.pop_back(); for(auto itt = it; itt != st.end(); itt++){ if(sz(ls) == 0 || ls.back()+len < *itt) ls.pb(*itt); } return sz(ls); }
#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...