#include <bits/stdc++.h>
#include "elephants.h"
using namespace std;
int n;
int l;
int *x;
unordered_map<int,int>mp;
vector<int>uni;
void init(int N, int L, int X[])
{
n = N;
l=L;
x=X;
for(int i = 0;i<n;i++){
mp[x[i]]++;
}
for(pair<int,int>p:mp){
uni.push_back(p.first);
}
sort(uni.begin(),uni.end());
}
int update(int i, int y)
{
mp[x[i]]--;
if(mp[x[i]]==0){
mp.erase(x[i]);
uni.erase(lower_bound(uni.begin(),uni.end(),x[i]));
}
x[i]=y;
mp[x[i]]++;
if(mp[x[i]]==1){
int ind = lower_bound(uni.begin(),uni.end(),x[i])-uni.begin();
uni.insert(uni.begin()+ind,x[i]);
}
int ans = 1;
int las = uni[0];
for(int i : uni){
if(i-las>l){
las=i;
ans++;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
444 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
444 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
536 ms |
2496 KB |
Output is correct |
8 |
Correct |
1125 ms |
2904 KB |
Output is correct |
9 |
Correct |
1631 ms |
5480 KB |
Output is correct |
10 |
Correct |
1809 ms |
5228 KB |
Output is correct |
11 |
Correct |
1798 ms |
4972 KB |
Output is correct |
12 |
Correct |
4869 ms |
5224 KB |
Output is correct |
13 |
Correct |
2100 ms |
4968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
444 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
536 ms |
2496 KB |
Output is correct |
8 |
Correct |
1125 ms |
2904 KB |
Output is correct |
9 |
Correct |
1631 ms |
5480 KB |
Output is correct |
10 |
Correct |
1809 ms |
5228 KB |
Output is correct |
11 |
Correct |
1798 ms |
4972 KB |
Output is correct |
12 |
Correct |
4869 ms |
5224 KB |
Output is correct |
13 |
Correct |
2100 ms |
4968 KB |
Output is correct |
14 |
Correct |
441 ms |
3760 KB |
Output is correct |
15 |
Correct |
3598 ms |
4024 KB |
Output is correct |
16 |
Execution timed out |
9100 ms |
5996 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
444 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
536 ms |
2496 KB |
Output is correct |
8 |
Correct |
1125 ms |
2904 KB |
Output is correct |
9 |
Correct |
1631 ms |
5480 KB |
Output is correct |
10 |
Correct |
1809 ms |
5228 KB |
Output is correct |
11 |
Correct |
1798 ms |
4972 KB |
Output is correct |
12 |
Correct |
4869 ms |
5224 KB |
Output is correct |
13 |
Correct |
2100 ms |
4968 KB |
Output is correct |
14 |
Correct |
441 ms |
3760 KB |
Output is correct |
15 |
Correct |
3598 ms |
4024 KB |
Output is correct |
16 |
Execution timed out |
9100 ms |
5996 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |