답안 #59958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
59958 2018-07-23T11:27:05 Z theknife2001 코끼리 (Dancing Elephants) (IOI11_elephants) C++17
컴파일 오류
0 ms 0 KB
#include "elephants.h"
#include<bits/stdc++.h>

int n;
int ind[50005];
int ind1[50005];
int l;

void init(int N, int L, int X[])
{
    for(int i=0;i<N;i++)
        ind[i]=X[i];
    l=L;
    n=N;
}

int update(int i, int y)
{
    ind[i]=y;
    for(int i=0;i<n;i++)
        ind1[i]=ind[i];
    sort(ind1,ind1+n);
    int cnt=1;
    int last=ind1[0];
    for(int i=1;i<n;i++)
    {
        if(last+l<ind1[i])
        {
            cnt++;
            last=ind1[i];
        }
    }
    return cnt;
}

Compilation message

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:22:5: error: 'sort' was not declared in this scope
     sort(ind1,ind1+n);
     ^~~~
elephants.cpp:22:5: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from elephants.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4856:5: note:   'std::sort'
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^~~~