#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include "elephants.h"
using namespace std;
#define INF 1145141919
#define rep(i, n) for (int i=0; i<(n); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define _1 first
#define _2 second
typedef pair<int, int> P;
int N, L;
int A[150000], B[150000];
void init(int n, int l, int X[]) {
N = n, L = l;
rep(i, N) A[i] = B[i] = X[i];
}
int lb(int len, int x) {
int lo = -1, hi = len;
while (hi - lo > 1) {
int mid = (lo + hi) / 2;
if (B[mid] >= x) hi = mid;
else lo = mid;
}
return hi;
}
int update(int i, int y) {
// remove A[i]
//int pos = lower_bound(B, B+N, A[i])-B;
int pos = lb(N, A[i]);
for (int x=pos; x<N-1; x++) B[x] = B[x+1];
B[N-1] = 0;
// insert y
A[i] = y;
//pos = lower_bound(B, B+N-1, y+1)-B;
pos = lb(N-1, y+1);
for (int x=N-2; x>=pos; x--) B[x+1] = B[x];
B[pos] = y;
//
int until = B[0]+L, c = 1;
rep(i, N) {
if (B[i] > until) until = B[i]+L, c++;
}
return c;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
18812 KB |
Output is correct |
2 |
Correct |
0 ms |
18812 KB |
Output is correct |
3 |
Correct |
0 ms |
18812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
18812 KB |
Output is correct |
2 |
Correct |
0 ms |
18812 KB |
Output is correct |
3 |
Correct |
0 ms |
18812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2923 ms |
18812 KB |
Output is correct |
2 |
Correct |
4089 ms |
18812 KB |
Output is correct |
3 |
Correct |
4319 ms |
18812 KB |
Output is correct |
4 |
Correct |
5143 ms |
18812 KB |
Output is correct |
5 |
Correct |
4733 ms |
18812 KB |
Output is correct |
6 |
Execution timed out |
9000 ms |
18812 KB |
Execution timed out |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2869 ms |
18812 KB |
Output is correct |
2 |
Correct |
7736 ms |
18812 KB |
Output is correct |
3 |
Execution timed out |
9000 ms |
18812 KB |
Execution timed out |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
9000 ms |
18812 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |