Submission #484284

# Submission time Handle Problem Language Result Execution time Memory
484284 2021-11-02T20:10:19 Z rainboy Po (COCI21_po) C
70 / 70
14 ms 812 KB
#include <stdio.h>

#define N	100000

int main() {
	static int aa[N], qu[N];
	int n, i, cnt, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	ans = n, cnt = 0;
	for (i = 0; i < n; i++) {
		while (cnt && aa[qu[cnt - 1]] > aa[i])
			cnt--;
		if (aa[i] == 0 || cnt && aa[qu[cnt - 1]] == aa[i])
			ans--;
		qu[cnt++] = i;
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:16:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   16 |   if (aa[i] == 0 || cnt && aa[qu[cnt - 1]] == aa[i])
      |                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
Main.c:11:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 5 ms 444 KB Output is correct
5 Correct 8 ms 476 KB Output is correct
6 Correct 13 ms 812 KB Output is correct
7 Correct 14 ms 644 KB Output is correct