#include "elephants.h"
#include<set>
#include<iostream>
using namespace std;
typedef std::multiset<int>::iterator mit;
int n;
multiset<int> s;
int l;
int positions[1000000];
void init(int N, int L, int X[])
{
l=L;
n=N;
for(int i=0;i<n;i++){
positions[i]=X[i];
s.insert(X[i]);
}
}
int update(int i, int y)
{
mit it=s.find(positions[i]);
s.erase(it);
s.insert(y);
it=s.begin();
int cnt=0;
while(it!=s.end()){
int next=*it+l;
it=s.upper_bound(next);
cnt++;
}positions[i]=y;
return cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
508 KB |
Output is correct |
4 |
Correct |
3 ms |
516 KB |
Output is correct |
5 |
Correct |
4 ms |
576 KB |
Output is correct |
6 |
Correct |
3 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
508 KB |
Output is correct |
4 |
Correct |
3 ms |
516 KB |
Output is correct |
5 |
Correct |
4 ms |
576 KB |
Output is correct |
6 |
Correct |
3 ms |
596 KB |
Output is correct |
7 |
Execution timed out |
9024 ms |
2780 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
508 KB |
Output is correct |
4 |
Correct |
3 ms |
516 KB |
Output is correct |
5 |
Correct |
4 ms |
576 KB |
Output is correct |
6 |
Correct |
3 ms |
596 KB |
Output is correct |
7 |
Execution timed out |
9024 ms |
2780 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
508 KB |
Output is correct |
4 |
Correct |
3 ms |
516 KB |
Output is correct |
5 |
Correct |
4 ms |
576 KB |
Output is correct |
6 |
Correct |
3 ms |
596 KB |
Output is correct |
7 |
Execution timed out |
9024 ms |
2780 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |