Submission #1307922


Source Code Expand

#include<stdio.h>
#include<algorithm>
typedef long long LL;
using namespace std;
int main() {
	int n;
	while(scanf("%d",&n)!=EOF) {
		int cnt=1;
		int tm,flag=-1;
		scanf("%d",&tm);
		for(int i=1; i<n; i++) {
			int t;
			scanf("%d",&t);
			if(t==tm)
				continue;
			if(t<tm) {
				if(flag==1) {
					cnt++;
					flag=-1;
				} else if(flag==-1)
					flag=0;
			} else if(t>tm) {
				if(flag==0) {
					cnt++;
					flag=-1;
				} else if(flag==-1)
					flag=1;
			}
			tm=t;
		}

		printf("%d\n",cnt);
	}
	return 0;
}

Submission Info

Submission Time
Task A - Sorted Arrays
User BoilTask
Language C++14 (GCC 5.4.1)
Score 300
Code Size 554 Byte
Status AC
Exec Time 12 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&tm);
                  ^
./Main.cpp:13:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, 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
AC × 3
AC × 17
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 7 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 12 ms 128 KB
subtask_1_05.txt AC 11 ms 128 KB
subtask_1_06.txt AC 12 ms 128 KB
subtask_1_07.txt AC 12 ms 128 KB
subtask_1_08.txt AC 12 ms 128 KB
subtask_1_09.txt AC 12 ms 128 KB
subtask_1_10.txt AC 1 ms 128 KB
subtask_1_11.txt AC 1 ms 128 KB