This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "elephants.h"
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
int n;
int l;
pair<int,int> x[150005];
int pos[150005];
void init(int N, int L, int X[])
{
n = N;
l = L;
for(int i=0; i<n; i++) {
x[i] = make_pair(X[i], i);
}
sort(x, x+n);
for(int i=0; i<n; i++) {
pos[x[i].second] = i;
}
}
int update(int i, int y)
{
int ptr = pos[i];
x[ptr].first = y;
while(ptr > 0 && x[ptr] < x[ptr-1]) {
swap(pos[x[ptr].second], pos[x[ptr-1].second]);
swap(x[ptr], x[ptr-1]);
--ptr;
}
while(ptr < n-1 && x[ptr] > x[ptr+1]) {
swap(pos[x[ptr].second], pos[x[ptr+1].second]);
swap(x[ptr], x[ptr+1]);
++ptr;
}
int past = x[0].first;
int ans = 1;
for(int i=1; i<n; i++) {
if(past+l < x[i].first) {
ans++;
past = x[i].first;
}
}
return ans;
}
Compilation message (stderr)
elephants.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
6 | #pragma GCC optimization ("O3")
|
elephants.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
7 | #pragma GCC optimization ("unroll-loops")
|
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |