# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1007380 | c2zi6 | Dancing Elephants (IOI11_elephants) | C++14 | 9 ms | 10588 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "elephants.h"
int l;
int m = 0;
int st[800];
struct BUCKET {
int n = 0;
int b[800];
int cnt[800];
int mx[800];
void rem(int x) {
while (b[n-1] > x) {
st[m++] = b[--n];
}
--n;
while (m) {
b[n++] = st[--m];
}
}
void add(int x) {
while (n && b[n-1] > x) {
st[m++] = b[--n];
}
b[n++] = x;
while (m) {
b[n++] = st[--m];
}
}
void recalc() {
reprl(i, n-1, 0) {
int j = upper_bound(b, b+n, b[i] + l) - b;
if (i == n) {
cnt[i] = 1;
mx[i] = b[i]+l;
} else {
cnt[i] = cnt[j]+1;
mx[i] = mx[j];
}
}
}
void print() {
rep(i, n) cout << b[i] << " "; cout << endl;
rep(i, n) cout << cnt[i] << " "; cout << endl;
rep(i, n) cout << mx[i] << " "; cout << endl;
}
};
int n;
int a[60000];
BUCKET buck;
void init(int N, int L, int X[]) {
n = N;
l = L;
rep(i, n) a[i] = X[i];
rep(i, n) buck.add(a[i]);
buck.recalc();
}
int update(int i, int y) {
buck.rem(a[i]);
a[i] = y;
buck.add(a[i]);
buck.recalc();
return buck.cnt[0];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |