Submission #1220990
Source Code Expand
#include <iostream> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <vector> #include <utility> #include <iomanip> #include <sstream> #include <bitset> #include <cstdlib> #include <iterator> #include <algorithm> #include <cstdio> #include <cctype> #include <cmath> #include <math.h> #include <ctime> #include <cstring> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; #define INF (int)1e9 #define EPS 1e-9 int mod = 1000000007; long long pwr(long long a,long long b,long long mod) { if(b==0) return 1; long long temp=pwr(a,b/2,mod); temp=(temp*temp)%mod; if(b&1) temp=(temp*a)%mod; return temp; } long long pwr(long long a,long long b) { if(b==0) return 1; long long temp=pwr(a,b/2); temp=(temp*temp); if(b&1) temp=(temp*a); return temp; } bool* isPrime; void generatePrimeSieve(const int lim) { isPrime=(bool *)malloc(lim+1); memset(isPrime,true,lim+1); isPrime[0]=false; isPrime[1]=false; for(int i=2;i<=lim;++i) if(isPrime[i]) for(int j=i+i;j<=lim;j+=i) isPrime[j]=false; } long long modularInverse(long long a,long long m) { return pwr(a,m-2,m); } int a[100005]; int main() { ios::sync_with_stdio(false); // freopen("input.txt", "r", stdin); int n; cin>>n; for (int i = 0; i < n; ++i) cin>>a[i]; int ans = 0; for (int i = 1; i < n-1; ++i) { if(a[i] > a[i-1] && a[i] > a[i+1]) ans++; if(a[i] < a[i-1] && a[i] < a[i+1]) ans++; } cout<<ans+1; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | vivekmufc |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1773 Byte |
Status | WA |
Exec Time | 13 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 256 KB |
sample_02.txt | WA | 1 ms | 256 KB |
sample_03.txt | AC | 1 ms | 256 KB |
subtask_1_01.txt | WA | 7 ms | 512 KB |
subtask_1_02.txt | AC | 6 ms | 512 KB |
subtask_1_03.txt | WA | 4 ms | 384 KB |
subtask_1_04.txt | WA | 12 ms | 640 KB |
subtask_1_05.txt | AC | 11 ms | 640 KB |
subtask_1_06.txt | WA | 12 ms | 640 KB |
subtask_1_07.txt | WA | 11 ms | 640 KB |
subtask_1_08.txt | AC | 13 ms | 640 KB |
subtask_1_09.txt | WA | 12 ms | 640 KB |
subtask_1_10.txt | AC | 1 ms | 256 KB |
subtask_1_11.txt | AC | 1 ms | 256 KB |