This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define range(it, a, b) for (ll it = a; it < b; it++)
#define all(x) begin(x), end(x)
#define ll long long
#define ull unsigned long long
#define INF64 ((ll) 1 << 62)
#define INF32 (1 << 30)
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define pqueue priority_queue
#define ptr(A) shared_ptr<A>
using namespace std;
struct Ele {
ll i, p;
};
bool operator < (const Ele& a, const Ele& b) {
if (a.p == b.p)
return a.i < b.i;
return a.p < b.p;
}
int n, l;
multiset<Ele> ms;
vector<ll> pos;
void init(int N, int L, int X[]) {
n = N; l = L;
pos.resize(n);
range(i, 0, n) {
pos[i] = X[i];
ms.insert({i, pos[i]});
}
}
int update(int i, int y) {
ms.erase({i, pos[i]});
pos[i] = y;
ms.insert({i, pos[i]});
int nxt = 0;
int cnt = 0;
while (nxt <= (*ms.rbegin()).p) {
// cout << "Covered all but the ones after: ";
// cout << nxt << ' ';
// cout << "Maximum is " << (*ms.rbegin()).p << '\n';
cnt++;
auto lb = ms.lower_bound({0, nxt});
nxt = (*lb).p+l+1;
if (cnt > 100)
return -1;
}
cout << '\n';
return cnt;
}
# | 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... |