# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94264 | 2019-01-17T08:39:12 Z | Scayre | Dancing Elephants (IOI11_elephants) | C++14 | 0 ms | 0 KB |
#include "grader.h" #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio> #include <limits> #include <complex> #include <vector> #include <climits> #include <cstring> #include <cstdlib> #include <fstream> #include <numeric> #include <sstream> #include <cassert> #include <iomanip> #include <iostream> #include <algorithm> using namespace std; #define ll long long const int MXN = 5e5 + 7; set<int> s; int a[MXN]; int Lm; int update(int id, int nv) { s.erase(a[id]); a[id]=nv; s.insert(nv); int cur=(*s.begin()); int ans=0; while(1){ auto pos=s.upper_bound(cur+Lm); if(pos!=s.end() && *pos>cur+Lm && *pos!=0){ ans++; cur=*pos; } else break; } return ans+1; } void init(int n, int l, int xs[]) { for(int i=0;i<n;i++){ a[i]=xs[i]; s.insert(xs[i]); } Lm=l; return; }