제출 #747987

#제출 시각아이디문제언어결과실행 시간메모리
747987Dan4Life코끼리 (Dancing Elephants) (IOI11_elephants)C++17
26 / 100
15 ms2712 KiB
#include "elephants.h" #include <bits/stdc++.h> using namespace std; const int mxN = (int)1.5e5+10; const int B = 240; set<int> S; int n, L, ok, p[mxN/B]; unordered_map<int,int> b; vector<pair<int,int>> block[mxN/B]; void ins(int x){ b[x]++; if(b[x]!=1) return; if(ok) { S.insert(x); return; } } void del(int x){ b[x]--; if(b[x]) return; if(ok) { S.erase(x); return;} } void init(int N, int l, int X[]) { n = N; L = l; if(L > mxN/B or 1) ok=1; for(int i = 0; i < n; i++) p[i]=X[i], ins(p[i]); } int update(int i, int y) { del(p[i]); p[i]=y; ins(y); int ans = 0; if(ok){ auto itr = S.begin(); while(itr!=S.end()) itr = S.upper_bound(*itr+L), ans++; return ans; } return ans; }
#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...