#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 |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
2 ms |
6488 KB |
Output is correct |
5 |
Correct |
2 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
2 ms |
6488 KB |
Output is correct |
5 |
Correct |
2 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6488 KB |
Output is correct |
7 |
Incorrect |
17 ms |
10584 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
2 ms |
6488 KB |
Output is correct |
5 |
Correct |
2 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6488 KB |
Output is correct |
7 |
Incorrect |
17 ms |
10584 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
2 ms |
6488 KB |
Output is correct |
5 |
Correct |
2 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6488 KB |
Output is correct |
7 |
Incorrect |
17 ms |
10584 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |