제출 #348629

#제출 시각아이디문제언어결과실행 시간메모리
348629tengiz05코끼리 (Dancing Elephants) (IOI11_elephants)C++17
컴파일 에러
0 ms0 KiB
#include "elephants.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
int n, len;
int a[50000];
set<int> s;
void init(int N, int L, int X[]){
	n=N;
	len = L;
	for(int i=0;i<n;i++)a[i] = X[i];
	for(int i=0;i<n;i++)s.insert(a[i]);
}
int ans;
int update(int i, int y){
	s.erase(a[i]);
	a[i] = y;ans=1;
	s.insert(a[i]);
	int lst=*s.begin();
	for(int &x : s){
		if(x == lst)continue;
		if(x-lst > len){
			ans++;
			lst=x;
		}
	}
	return ans;
}

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

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:22:15: error: binding reference of type 'int&' to 'const int' discards qualifiers
   22 |  for(int &x : s){
      |               ^