Submission #348629

#TimeUsernameProblemLanguageResultExecution timeMemory
348629tengiz05코끼리 (Dancing Elephants) (IOI11_elephants)C++17
Compilation error
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; }

Compilation message (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){
      |               ^