제출 #1078311

#제출 시각아이디문제언어결과실행 시간메모리
1078311horiaboeriuInfinite Race (EGOI24_infiniterace2)C++17
100 / 100
258 ms2008 KiB
#include <stdio.h>
#include <stdlib.h>
#define MAXN 200000
char f[MAXN];//in f[x] este 0 daca x este in fata si 1 daca ea este in fata pe teren
int rez[MAXN];
int main()
{
    int n, q, i, x, rez, j;
    scanf("%d%d", &n, &q);
    rez = 0;
    for (i = 0; i < q; i++) {
        scanf("%d", &x);
        if (x < 0) {
            f[-x] = 0;
        } else {
            if (f[x] > 0) {
                rez++;
                //acum este in spatele tutror, mai putin a lui x
                for (j = 0; j < n; j++) {
                    f[j] = 0;
                }
            }
            f[x] = 1;
        }
    }
    printf("%d\n", rez);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d%d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         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...