Submission #1106320

# Submission time Handle Problem Language Result Execution time Memory
1106320 2024-10-30T01:09:15 Z Zero_OP Dancing Elephants (IOI11_elephants) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

int n, l;
vector<int> x;
map<int, int> cnt;

void init(int N, int L, vector<int> X){
    n = N;
    l = L;
    x = X;

    for(int i = 0; i < N; ++i){
        ++cnt[X[i]];
    }
}

int greedy(){
    int last = -1, ans = 0;
    for(auto [x, y] : cnt){
        if(!y) assert(false);
        if(last < x) ++ans, last = x + l;
    }
    return ans;
}

int update(int i, int y){
    if(!(--cnt[x[i]])) cnt.erase(cnt.find(x[i]));
    x[i] = y;
    ++cnt[x[i]];

    return greedy();
}

#ifdef LOCAL
    int main(){
        ios_base::sync_with_stdio(0); cin.tie(0);

        init(4, 10, {10, 15, 17, 20});
        cout << update(2, 16) << '\n';
        cout << update(1, 25) << '\n';
        cout << update(3, 35) << '\n';
        cout << update(0, 38) << '\n';
        cout << update(2, 0) << '\n';

        return 0;
    }
#endif // LOCAL

Compilation message

elephants.cpp: In function 'int greedy()':
elephants.cpp:21:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   21 |     for(auto [x, y] : cnt){
      |              ^
/usr/bin/ld: /tmp/ccLhb0Yn.o: in function `main':
grader.cpp:(.text.startup+0x27): undefined reference to `init(int, int, int*)'
collect2: error: ld returned 1 exit status