Submission #1221911
Source Code Expand
#include <stdio.h> enum State { FIRST, INCREASE, DECREASE }; int main(void) { int N, i, A[2], count = 1, state = FIRST; scanf("%d", &N); scanf("%d", &A[0]); for (i = 0; i < N - 1; i++) { scanf("%d", &A[1]); switch (state) { case FIRST: if (A[0] < A[1]) state = INCREASE; else if (A[0] > A[1]) state = DECREASE; break; case INCREASE: if (A[0] > A[1]) { state = FIRST; count++; } break; case DECREASE: if (A[0] < A[1]) { state = FIRST; count++; } break; } A[0] = A[1]; } printf("%d\n", count); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | shiita0903 |
Language | C (GCC 5.4.1) |
Score | 300 |
Code Size | 619 Byte |
Status | AC |
Exec Time | 14 ms |
Memory | 128 KB |
Compile Error
./Main.c: In function ‘main’: ./Main.c:8:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.c:9:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &A[0]); ^ ./Main.c:11:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &A[1]); ^
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 | 0 ms | 128 KB |
sample_02.txt | AC | 0 ms | 128 KB |
sample_03.txt | AC | 0 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 | 14 ms | 128 KB |
subtask_1_10.txt | AC | 0 ms | 128 KB |
subtask_1_11.txt | AC | 1 ms | 128 KB |