Submission #703233

#TimeUsernameProblemLanguageResultExecution timeMemory
703233rainboyGlobal Warming (NOI13_gw)C11
23 / 40
318 ms18384 KiB
#include <stdio.h> #define N 1000000 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 main() { static int ii[N]; static char active[N]; int n, i, i_, j, k, k_, a; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &aa[i]); for (i = 0; i < n; i++) ii[i] = i; sort(ii, 0, n); k = 0, k_ = 0; for (j = n - 1; j >= 0; j = i) { i = j, a = aa[ii[j]]; while (i >= 0 && aa[ii[i]] == a) { i_ = ii[i--]; k++; active[i_] = 1; if (i_ > 0 && active[i_ - 1]) k--; if (i_ + 1 < n && active[i_ + 1]) k--; k_ = max(k_, k); } } printf("%d\n", k_); return 0; }

Compilation message (stderr)

gw.c: In function 'main':
gw.c:39:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
gw.c:41:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |   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...