Submission #1221513


Source Code Expand

//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbg=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int n;
int main()
{
	geti(n);
	int mn=Imx,mx=0,ans=1;
	bool f=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		geti(x);
		if(mx==0)mn=mx=x;
		else if(mn==mx)
		{
			if(x<mn)mn=x,f=0;
			else mx=x,f=1;
		}
		else
		{
			if(f)
			{
				if(x<mx)mn=mx=x,ans++;
				mx=max(mx,x);
			}
			else
			{
				if(x>mn)mn=mx=x,ans++;
				mn=min(mn,x);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Submission Info

Submission Time
Task A - Sorted Arrays
User fizzydavid
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1670 Byte
Status AC
Exec Time 9 ms
Memory 256 KB

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 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 6 ms 256 KB
subtask_1_02.txt AC 5 ms 256 KB
subtask_1_03.txt AC 3 ms 256 KB
subtask_1_04.txt AC 9 ms 256 KB
subtask_1_05.txt AC 9 ms 256 KB
subtask_1_06.txt AC 9 ms 256 KB
subtask_1_07.txt AC 9 ms 256 KB
subtask_1_08.txt AC 9 ms 256 KB
subtask_1_09.txt AC 9 ms 256 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt AC 1 ms 256 KB