제출 #1249121

#제출 시각아이디문제언어결과실행 시간메모리
1249121redacode코끼리 (Dancing Elephants) (IOI11_elephants)C++20
컴파일 에러
0 ms0 KiB
#include "elephants.h"
#include "bits/stdc++.h"
using namespace std;
int n;
int l;
bool cmp(pair<int, int>& a, 
        pair<int, int>& b) 
{ 
    return a.second < b.second; 
} 

vector<pair<int, int> > A; 

void sort_map(map<int, int>& M) 
{ 

    for (auto& it : M) { 
        A.push_back(it); 
    } 

    sort(A.begin(), A.end(), cmp); 

} 

map<int,int> pos;

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



int update(int i, int y)
{
   pos[i]=y;
   sort_map(pos);
   int cnt =0;
   int start = A[0].second;
   for(int i=1;i<n;i++){
       if(A[i].second-start>l){
           start = A[i].second;
           cnt++;
           if(i==n-1) cnt++
       }
   }
   return cnt;
}

컴파일 시 표준 에러 (stderr) 메시지

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:48:28: error: expected ';' before '}' token
   48 |            if(i==n-1) cnt++
      |                            ^
      |                            ;
   49 |        }
      |        ~