Submission #118254

#TimeUsernameProblemLanguageResultExecution timeMemory
118254MAMBADancing Elephants (IOI11_elephants)C++17
26 / 100
9071 ms3064 KiB
#include "elephants.h" #include <bits/stdc++.h> using namespace std; inline void read() {} template <class S> inline void read(S &arg) { cin >> arg; } template <class S> inline void readA(S Lptr, S Rptr) { while (Lptr != Rptr) { read(*Lptr); Lptr++; } } template <class S, class... T> inline void read(S &arg, T &... rest) { read(arg); read(rest...); } inline void write() {} template <class S> inline void write(S arg) { cout << arg; } template <class S> inline void writeA(S Lptr, S Rptr, char C_ = ' ') { if (Lptr != Rptr) { write(*Lptr); Lptr++; } while (Lptr != Rptr) { write(C_); write(*Lptr); Lptr++; } } template <class S, class... T> inline void write(S arg, T... rest) { write(arg); write(' '); write(rest...); } #define rep(i, j, k) for (int i = j; i < (int)k; i++) #define pb push_back #define mt make_tuple #define all(x) x.begin(), x.end() typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; template <class T, class S> inline bool smin(T &a, S b) { return (T)b < a ? a = b, 1 : 0; } template <class T, class S> inline bool smax(T &a, S b) { return a < (T)b ? a = b, 1 : 0; } constexpr int MOD = 1e9 + 7; constexpr int N = 1e6 + 10; template <typename T> inline T mod(T &v) { return v = (v % MOD + MOD) % MOD; } template <typename S, typename T> inline S add(S &l, T r) { return mod(l += r); } ll po(ll v, ll u) { return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1; } int n, l, pos[N]; multiset<int> ms; void init(int n_, int L, int X[]) { l = L; n = n_; rep(i, 0, n) { pos[i] = X[i]; ms.insert(X[i]); } } int update(int i, int y) { ms.erase(ms.find(pos[i])); pos[i] = y; ms.insert(y); int res = 0; int last = -1e9; for (auto e : ms) if (e - last > l) { res++; last = e; } return res; }
#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...