제출 #1130248

#제출 시각아이디문제언어결과실행 시간메모리
1130248sohamsen15코끼리 (Dancing Elephants) (IOI11_elephants)C++20
26 / 100
9086 ms1092 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 999999; int a[50005]; int n, l; void init(int N, int L, int X[]) { n = N; l = L; for (int i = 0; i < n; i++) a[i] = X[i]; } int getMax(int arr[], int n) { int mx = arr[0]; for (int i = 1; i < n; i++) if (arr[i] > mx) mx = arr[i]; return mx; } void countSort(int arr[], int n, int exp) { int output[n]; int i, count[10] = { 0 }; for (i = 0; i < n; i++) count[(arr[i] / exp) % 10]++; for (i = 1; i < 10; i++) count[i] += count[i - 1]; for (i = n - 1; i >= 0; i--) { output[count[(arr[i] / exp) % 10] - 1] = arr[i]; count[(arr[i] / exp) % 10]--; } for (i = 0; i < n; i++) arr[i] = output[i]; } void radixSort(int arr[], int n) { int m = getMax(arr, n); for (int exp = 1; m / exp > 0; exp *= 10) countSort(arr, n, exp); } int update(int idx, int y) { a[idx] = y; int b[n]; for (int i = 0; i < n; i++) b[i] = a[i]; radixSort(b, n); int ans = 0; for (int i = 0; i < n;) { ans++; bool done = false; for (int j = i + 1; j < n; j++) { if (b[j] - b[i] > l) { done = true; i = j; break; } else if (j == n - 1) { i = n; done = true; } } if (!done) i++; } 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...