Submission #1241677

#TimeUsernameProblemLanguageResultExecution timeMemory
1241677GabrielDancing Elephants (IOI11_elephants)C++20
10 / 100
0 ms328 KiB
#include "elephants.h" #include "bits/stdc++.h" using namespace std; int n, l; vector<int> a; unordered_map<int, int> Mapa; void init(int N, int L, int X[]){ n = N; l = L; for(int i = 0; i < n; i++){ Mapa[i] = i; a.push_back(X[i]); } } int update(int i, int y){ a[Mapa[i]] = y; for(int j = Mapa[i]; j > 0; j--){ if(a[j] >= a[j - 1]) break; else { swap(a[j], a[j - 1]); swap(Mapa[j], Mapa[j - 1]); } } for(int j = Mapa[i]; j < n - 1; j++){ if(a[j] <= a[j + 1]) break; else { swap(a[j], a[j + 1]); swap(Mapa[j], Mapa[j + 1]); } } int r = 0, p = -2; for(auto E: a){ if(p == -2){ r++; p = E; } else if(E > p + l){ r++; p = E; } } return r; }
#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...