이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "elephants.h"
using namespace std;
const int MAX_ELEPH=150*1000+5,INFINI=1000*1000*1000+5;
int nbEleph,taillePhoto;
pair<int,int> posTri[MAX_ELEPH];
void init(int N, int L, int X[]) {
nbEleph=N;
taillePhoto=L;
for (int i=0;i<nbEleph;i++) {
posTri[i]={X[i],i};
}
}
int calc() {
int ans=0,dernDeb=-INFINI;
for (int i=0;i<nbEleph;i++) {
if (dernDeb+taillePhoto<posTri[i].first) {
ans++;
dernDeb=posTri[i].first;
}
}
return ans;
}
int update(int posModif, int valNouv) {
int pos=0;
while (posTri[pos].second!=posModif) {
pos++;
}
posTri[pos].first=valNouv;
while (pos>0 and posTri[pos]<posTri[pos-1]) {
swap(posTri[pos-1],posTri[pos]);
pos--;
}
while (pos<nbEleph-1 and posTri[pos]>posTri[pos+1]) {
swap(posTri[pos],posTri[pos+1]);
pos++;
}
return calc();
}
# | 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... |