Submission #471175

#TimeUsernameProblemLanguageResultExecution timeMemory
471175rainboyDoktor (COCI17_doktor)C11
100 / 100
89 ms13096 KiB
#include <stdio.h> #define N 500000 int main() { static int pp[N], qq[N], kk[N], ll[N + N]; int n, i, i_, j_, k_; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &pp[i]), pp[i]--; qq[pp[i]] = i; if (i == pp[i]) kk[i]++; } for (i = 1; i < n; i++) kk[i] += kk[i - 1]; i_ = j_ = k_ = -1; for (i = n - 1; i >= 0; i--) { int k; if (i <= pp[i]) { k = ++ll[i + pp[i]] - (kk[pp[i]] - (i == 0 ? 0 : kk[i - 1])); if (k_ < k) k_ = k, i_ = i, j_ = pp[i]; } if (i != pp[i] && i <= qq[i]) { k = ++ll[i + qq[i]] - (kk[qq[i]] - (i == 0 ? 0 : kk[i - 1])); if (k_ < k) k_ = k, i_ = i, j_ = qq[i]; } } printf("%d %d\n", pp[i_] + 1, pp[j_] + 1); return 0; }

Compilation message (stderr)

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