#include "elephants.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define OK cout << "OK" << endl;
int n;
int len, pos[50003];
vector <int> ls;
set <int> st;
void init(int N, int L, int X[]){
n = N;
if(n > 70000) exit(0);
len = L;
for(int i = 0; i < n; i++) pos[i] = X[i];
for(int i = 0; i < n; i++) st.insert(pos[i]);
for(auto to : st){
if(sz(ls) == 0 || ls.back()+len < to) ls.pb(to);
}
}
int update(int i, int y){
int prev = pos[i];
st.erase(st.find(pos[i]));
pos[i] = y;
st.insert(pos[i]);
auto it = st.lb(min(y, prev));
while(sz(ls) && ls.back() >= min(y, prev)) ls.pop_back();
for(auto itt = it; itt != st.end(); itt++){
if(sz(ls) == 0 || ls.back()+len < *itt) ls.pb(*itt);
}
return sz(ls);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
3376 ms |
1748 KB |
Output is correct |
8 |
Correct |
4547 ms |
2072 KB |
Output is correct |
9 |
Execution timed out |
9073 ms |
3948 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
3376 ms |
1748 KB |
Output is correct |
8 |
Correct |
4547 ms |
2072 KB |
Output is correct |
9 |
Execution timed out |
9073 ms |
3948 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
3376 ms |
1748 KB |
Output is correct |
8 |
Correct |
4547 ms |
2072 KB |
Output is correct |
9 |
Execution timed out |
9073 ms |
3948 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |