Submission #1241684

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