Submission #642861

#TimeUsernameProblemLanguageResultExecution timeMemory
642861rainboyTeam Contest (JOI22_team)C11
100 / 100
111 ms4168 KiB
#include <stdio.h> #define N 150000 unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } int *ww; 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 (ww[ii[j]] == ww[i_]) j++; else if (ww[ii[j]] < ww[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 xx[N], yy[N], zz[N], ii[N], jj[N], kk[N]; static char deleted[N]; int n, i, i_, j, j_, k, k_; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d%d%d", &xx[i], &yy[i], &zz[i]); for (i = 0; i < n; i++) ii[i] = jj[i] = kk[i] = i; ww = xx, sort(ii, 0, n); ww = yy, sort(jj, 0, n); ww = zz, sort(kk, 0, n); i = n - 1, j = n - 1, k = n - 1; while (1) { i_ = j_ = k_ = -1; while (i >= 0 && deleted[i_ = ii[i]]) i--; while (j >= 0 && deleted[j_ = jj[j]]) j--; while (k >= 0 && deleted[k_ = kk[k]]) k--; if (i < 0) { printf("-1\n"); return 0; } if (yy[i_] >= yy[j_] || zz[i_] >= zz[k_]) deleted[i_] = 1; else if (zz[j_] >= zz[k_] || xx[j_] >= xx[i_]) deleted[j_] = 1; else if (xx[k_] >= xx[i_] || yy[k_] >= yy[j_]) deleted[k_] = 1; else { printf("%d\n", xx[i_] + yy[j_] + zz[k_]); return 0; } } return 0; }

Compilation message (stderr)

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