Submission #1260297
Source Code Expand
#include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(void) { #define unknown 0 #define up 1 #define down 2 int trend = unknown; int count = 0; int n; scanf("%d", &n); if (n <= 2) { printf("1\n"); exit(0); } int prev; scanf("%d", &prev); int i; for (i = 1; i < n; ++i) { int current; scanf("%d", ¤t); switch (trend) { case up: if (prev > current) { count++; trend = unknown; } break; case down: if (prev < current) { count++; trend = unknown; } break; default: if (prev > current) trend = down; else if (prev < current) trend = up; break; } prev = current; } count++; printf("%d\n", count); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | kmnk1 |
Language | C (GCC 5.4.1) |
Score | 300 |
Code Size | 1010 Byte |
Status | AC |
Exec Time | 13 ms |
Memory | 128 KB |
Compile Error
./Main.c: In function ‘main’: ./Main.c:13:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.c:19:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &prev); ^ ./Main.c:23:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", ¤t); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 1 ms | 128 KB |
sample_02.txt | AC | 1 ms | 128 KB |
sample_03.txt | AC | 1 ms | 128 KB |
subtask_1_01.txt | AC | 8 ms | 128 KB |
subtask_1_02.txt | AC | 6 ms | 128 KB |
subtask_1_03.txt | AC | 4 ms | 128 KB |
subtask_1_04.txt | AC | 13 ms | 128 KB |
subtask_1_05.txt | AC | 13 ms | 128 KB |
subtask_1_06.txt | AC | 13 ms | 128 KB |
subtask_1_07.txt | AC | 13 ms | 128 KB |
subtask_1_08.txt | AC | 13 ms | 128 KB |
subtask_1_09.txt | AC | 13 ms | 128 KB |
subtask_1_10.txt | AC | 0 ms | 128 KB |
subtask_1_11.txt | AC | 1 ms | 128 KB |