Submission #447766

#TimeUsernameProblemLanguageResultExecution timeMemory
447766dxz05Dancing Elephants (IOI11_elephants)C++14
0 / 100
0 ms332 KiB
#include "elephants.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 3e2; int N, L; int X[MAXN], A[MAXN]; void init(int _N, int _L, int _X[]){ N = _N; L = _L; for (int i = 0; i < N; i++) X[i] = _X[i]; for (int i = 0; i < N; i++) A[i] = X[i]; sort(A, A + N); } int update(int pos, int val){ int ind = 0; for (int i = 0; i < N; i++){ if (A[i] == X[pos]) A[i] = val, ind = i; } if (X[pos] < val){ X[pos] = val; int j = ind; while (j < N - 1 && A[j] > A[j + 1]) { swap(A[j], A[j + 1]); j++; } } else { X[pos] = val; int j = ind; while (j > 1 && A[j] < A[j - 1]) { swap(A[j], A[j - 1]); j--; } } //for (int i = 0; i < N; i++) cerr << A[i] << ' '; cerr << endl; int ans = 1, last = A[0]; for (int i = 0; i < N; i++){ int x = A[i]; if (x - last > L){ ans++; last = x; } } return ans; }
#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...