Submission #1221266
Source Code Expand
#include<map> #include<set> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<cctype> #include<cstdlib> #include<cstring> #include<utility> #include<algorithm> #define fi first #define se second #define pb push_back #define mp make_pair #define For(i,x,y) for(int i=((int)x);i<=((int)y);i++) #define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--) #define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt) using namespace std; typedef long long ll; typedef unsigned int uint; typedef pair<int,int> pii; int rd() { char c=getchar(); int t=0,f=1; while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar(); while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f; } void wt(int x) { if (x<0) putchar('-'),wt(-x); else { if (x>9) wt(x/10); putchar(x%10+48); } } const int N=100035; int n,a[N],ans,lst,op; int main() { n=rd(),lst=rd(),ans=1; For (i,2,n) { a[i]=rd(); if (!op) { if (a[i]>lst) op=1; else if (a[i]<lst) op=-1; } else if ((op==1 && a[i]<lst) || (op==-1 && a[i]>lst)) ans++,op=0; lst=a[i]; } printf("%d\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | Ajatar |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1141 Byte |
Status | AC |
Exec Time | 10 ms |
Memory | 512 KB |
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 | 5 ms | 384 KB |
subtask_1_02.txt | AC | 5 ms | 384 KB |
subtask_1_03.txt | AC | 3 ms | 256 KB |
subtask_1_04.txt | AC | 9 ms | 512 KB |
subtask_1_05.txt | AC | 8 ms | 512 KB |
subtask_1_06.txt | AC | 9 ms | 512 KB |
subtask_1_07.txt | AC | 9 ms | 512 KB |
subtask_1_08.txt | AC | 10 ms | 512 KB |
subtask_1_09.txt | AC | 9 ms | 512 KB |
subtask_1_10.txt | AC | 0 ms | 128 KB |
subtask_1_11.txt | AC | 0 ms | 128 KB |