Submission #1221170
Source Code Expand
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
int N,A;
int main(){
scanf("%d%d" , &N , &A);
int ans = 1;
int z = 0;
repp(i,1,N){
int x;
scanf("%d" , &x);
if(A < x){
if(z > 0){
++ans;
z = 0;
} else {
z = -1;
}
} else if(A > x){
if(z < 0){
++ans;
z = 0;
} else {
z = 1;
}
}
A = x;
}
printf("%d\n" , ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Sorted Arrays |
User |
PIandS |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1043 Byte |
Status |
AC |
Exec Time |
12 ms |
Memory |
128 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d" , &N , &A);
^
./Main.cpp:32:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d" , &x);
^
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 |
12 ms |
128 KB |
subtask_1_05.txt |
AC |
12 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 |
0 ms |
128 KB |