#include <bits/stdc++.h>
#include "elephants.h"
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 15e4+10;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9+7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
pii arr[MAXN], aux[MAXN];
int l, n;
void init(int N, int L, int X[])
{
for(int i=0;i<N;i++) arr[i]={X[i], i};
l=L; n=N;
}
int update(int i, int y)
{
bool b=0;
int cnt=0;
for(int j=0;j<n;j++){
if(arr[j].se==i) continue;
if(!b && arr[j].fi>=y){
aux[cnt++]=mp(y, i);
b=1;
}
aux[cnt++]=arr[j];
}
if(!b) aux[cnt++]=mp(y, i);
for(int j=0;j<n;j++) arr[j]=aux[j];
int curr=-l-1, ans=0;
for(int j=0;j<n;j++){
pii u=arr[j];
if(u.fi<=curr+l) continue;
curr=u.fi;
ans++;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Correct |
2 ms |
10584 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Correct |
2 ms |
10584 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10584 KB |
Output is correct |
5 |
Correct |
2 ms |
10584 KB |
Output is correct |
6 |
Correct |
2 ms |
10584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Correct |
2 ms |
10584 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10584 KB |
Output is correct |
5 |
Correct |
2 ms |
10584 KB |
Output is correct |
6 |
Correct |
2 ms |
10584 KB |
Output is correct |
7 |
Correct |
2007 ms |
12824 KB |
Output is correct |
8 |
Correct |
3356 ms |
12864 KB |
Output is correct |
9 |
Correct |
5510 ms |
12900 KB |
Output is correct |
10 |
Correct |
5594 ms |
12900 KB |
Output is correct |
11 |
Correct |
5518 ms |
12904 KB |
Output is correct |
12 |
Execution timed out |
9068 ms |
12888 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Correct |
2 ms |
10584 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10584 KB |
Output is correct |
5 |
Correct |
2 ms |
10584 KB |
Output is correct |
6 |
Correct |
2 ms |
10584 KB |
Output is correct |
7 |
Correct |
2007 ms |
12824 KB |
Output is correct |
8 |
Correct |
3356 ms |
12864 KB |
Output is correct |
9 |
Correct |
5510 ms |
12900 KB |
Output is correct |
10 |
Correct |
5594 ms |
12900 KB |
Output is correct |
11 |
Correct |
5518 ms |
12904 KB |
Output is correct |
12 |
Execution timed out |
9068 ms |
12888 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10584 KB |
Output is correct |
2 |
Correct |
2 ms |
10584 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10584 KB |
Output is correct |
5 |
Correct |
2 ms |
10584 KB |
Output is correct |
6 |
Correct |
2 ms |
10584 KB |
Output is correct |
7 |
Correct |
2007 ms |
12824 KB |
Output is correct |
8 |
Correct |
3356 ms |
12864 KB |
Output is correct |
9 |
Correct |
5510 ms |
12900 KB |
Output is correct |
10 |
Correct |
5594 ms |
12900 KB |
Output is correct |
11 |
Correct |
5518 ms |
12904 KB |
Output is correct |
12 |
Execution timed out |
9068 ms |
12888 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |