Submission #392825

#TimeUsernameProblemLanguageResultExecution timeMemory
392825rainboyStudentsko (COCI14_studentsko)C11
100 / 100
2 ms372 KiB
#include <stdio.h> #define N 5000 int max(int a, int b) { return a > b ? a : b; } unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } int aa[N]; void sort(int *ii, int l, int r) { while (l < r) { int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp; while (j < k) if (aa[ii[j]] == aa[i_]) j++; else if (aa[ii[j]] < aa[i_]) { tmp = ii[i], ii[i] = ii[j], ii[j] = tmp; i++, j++; } else { k--; tmp = ii[j], ii[j] = ii[k], ii[k] = tmp; } sort(ii, l, i); l = k; } } int ft[N]; void update(int i, int n, int x) { while (i < n) { ft[i] = max(ft[i], x); i |= i + 1; } } int query(int i) { int x = 0; while (i >= 0) { x = max(x, ft[i]); i &= i + 1, i--; } return x; } int main() { static int ii[N]; int n, m, k, i; scanf("%d%d", &n, &k), m = n / k; for (i = 0; i < n; i++) { scanf("%d", &aa[i]); ii[i] = i; } sort(ii, 0, n); for (i = 0; i < n; i++) aa[ii[i]] = i / k; for (i = 0; i < n; i++) update(aa[i], m, query(aa[i]) + 1); printf("%d\n", n - query(m - 1)); return 0; }

Compilation message (stderr)

studentsko.c: In function 'main':
studentsko.c:57:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   57 |  scanf("%d%d", &n, &k), m = n / k;
      |  ^~~~~~~~~~~~~~~~~~~~~
studentsko.c:59:3: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   59 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
#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...
#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...