Submission #119730

#TimeUsernameProblemLanguageResultExecution timeMemory
119730nvmdavaDancing Elephants (IOI11_elephants)C++17
0 / 100
2 ms384 KiB
#include "elephants.h" #include <bits/stdc++.h> #define ss second #define ff first using namespace std; int n, l; pair<int, int> a[50005]; int loc[50005]; void sorter(int id){ while(id + 1 < n && a[id].ff > a[id + 1].ff){ swap(a[id], a[id + 1]); id++; } while(id && a[id].ff < a[id - 1].ff){ swap(a[id], a[id - 1]); id--; } } int count(){ int lst = a[0].ff; int res = 1; for(int i = 1; i < n; i++){ if(a[i].ff > lst + l){ res++; lst = a[i].ff; } } return res; } void init(int N, int L, int X[]){ n = N; l = L; for(int i = 0; i < N; i++){ a[i].first = X[i]; a[i].second = i; } } int update(int i, int y){ a[i].ff = y; sorter(i); return count(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...