Submission #345799

#TimeUsernameProblemLanguageResultExecution timeMemory
345799casperwangDancing Elephants (IOI11_elephants)C++14
26 / 100
9029 ms1644 KiB
#include "elephants.h" #include <bits/stdc++.h> #define All(x) x.begin(), x.end() #define pii pair<int,int> #define ff first #define ss second using namespace std; #define debug(args...) kout("[ " + string(#args) + " ]", args) void kout() { cerr << endl; } template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); } template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; } const int MAXN = 150000; int n, len; map <int,int> arr; vector <int> a; int ans; void init(int N, int L, int X[]) { n = N, len = L; ans = 0; arr.clear(); a.clear(), a.resize(N); for (int i = 0; i < n; i++) a[i] = X[i], arr[a[i]]++; } int solve() { auto it = arr.begin(); int cnt = 0; while (it != arr.end()) { cnt++; it = arr.upper_bound(it->ff + len); } return cnt; } int update(int i, int y) { arr[a[i]]--; if (!arr[a[i]]) arr.erase(a[i]); a[i] = y; arr[a[i]]++; return solve(); }
#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...