이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "elephants.h"
#include <iostream>
using namespace std;
long long int n,l,x[100005][2];
void init(int N, int L, int X[])
{
n = N,l = L;
for(int i=0;i<n;i++)
{
x[i][0]=X[i];
x[i][1]=i;
}
}
int update(int i, int y)
{
int t;
for(int j=0;j<n;j++)
{
if(x[j][1]==i)
{
t=j;
break;
}
}
i=t;
x[i][0]=y;
if(x[i][0]<x[i-1][0])
{
for(int j=i-1;j>=0;j--)
{
if(x[j+1][0]<x[j][0])
{
swap(x[j+1][0],x[j][0]);
swap(x[j+1][1],x[j][1]);
}
else break;
}
}
else
{
for(int j=i+1;j<n;j++)
{
//cout<<j<<endl;
if(x[j-1][0]>x[j][0])
{
swap(x[j-1][0],x[j][0]);
swap(x[j-1][1],x[j][1]);
}
else break;
}
}
//for(int i=0;i<n;i++)
//{
// cout<<x[i][0]<<" "<<x[i][1]<<" ";
//}
//cout<<endl;
long long int ans=1,now=x[0][0];
for(int i=1;i<n;i++)
{
if(x[i][0]-now>l)
{
ans++;
now=x[i][0];
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
elephants.cpp: In function 'int update(int, int)':
elephants.cpp:17:6: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
int t;
^
# | 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... |