Submission #1049291

#TimeUsernameProblemLanguageResultExecution timeMemory
1049291sleepntsheepInfinite Race (EGOI24_infiniterace2)C11
100 / 100
20 ms2000 KiB
#include <stdio.h> int sgn(int x) { return x < 0 ? -1 : x > 0 ? 1 : 0; } int main() { int n, q, z = 1; scanf("%d%d", &n, &q); static int f[200000] = { 0 }, lap[200000] = { 0 }; for (int x, y, i = 1; i <= q; ++i) { scanf("%d", &x); y = x * sgn(x); if (lap[y] != z) f[y] = 0; if (sgn(x) == -1) { f[y] = -1; lap[y] = z; } else { if (f[y] == 1) ++z; lap[y] = z; f[y] = 1; } } printf("%d\n", z - 1); }

Compilation message (stderr)

Main.c: In function 'main':
Main.c:9:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   scanf("%d%d", &n, &q);
      |   ^~~~~~~~~~~~~~~~~~~~~
Main.c:13:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", &x);
      |     ^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...