Submission #1220976
Source Code Expand
/* */ #pragma GCC optimize("O3") #define _CRT_SECURE_NO_WARNINGS #include <fstream> #include <iostream> #include <string> #include <complex> #include <math.h> #include <set> #include <vector> #include <map> #include <queue> #include <stdio.h> #include <stack> #include <algorithm> #include <list> #include <ctime> #include <memory.h> #include <assert.h> #define y0 sdkfaslhagaklsldk #define y1 aasdfasdfasdf #define yn askfhwqriuperikldjk #define j1 assdgsdgasghsf #define tm sdfjahlfasfh #define lr asgasgash #define norm asdfasdgasdgsd #define have adsgagshdshfhds #define ends asdgahhfdsfshdshfd #define eps 1e-12 #define M_PI 3.141592653589793 #define bs 1000000007 #define ldouble long double using namespace std; long long INF = 1e9; const int N = 1200031; int n,ar[N],ans; int main(){ //freopen("tree.in","r",stdin); //freopen("tree.out","w",stdout); //freopen("input.txt", "r", stdin); //freopen("out.txt", "w", stdout); ios_base::sync_with_stdio(0); //cin.tie(0); cin>>n; for (int i=1;i<=n;i++) { cin>>ar[i]; } int start=1; while (start<=n) { ++ans; int have_up=0; int have_down=0; int new_start=-1; for (int i=start+1;i<=n;i++) { if (ar[i]>ar[i-1]) have_up=1; if (ar[i]<ar[i-1]) have_down=1; if (have_up&&have_down) { new_start=i; break; } } if (new_start==-1) new_start=n+1; start=new_start; } cout<<ans<<endl; cin.get(); cin.get(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | LeBron |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1533 Byte |
Status | AC |
Exec Time | 12 ms |
Memory | 764 KB |
Compile Error
./Main.cpp:36:0: warning: "M_PI" redefined #define M_PI 3.141592653589793 ^ In file included from /usr/include/c++/5/cmath:44:0, from /usr/include/c++/5/complex:44, from ./Main.cpp:9: /usr/include/math.h:372:0: note: this is the location of the previous definition # define M_PI 3.14159265358979323846 /* pi */ ^
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 | 5 ms | 764 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | AC | 1 ms | 256 KB |
subtask_1_01.txt | AC | 8 ms | 512 KB |
subtask_1_02.txt | AC | 6 ms | 512 KB |
subtask_1_03.txt | AC | 4 ms | 384 KB |
subtask_1_04.txt | AC | 12 ms | 640 KB |
subtask_1_05.txt | AC | 11 ms | 640 KB |
subtask_1_06.txt | AC | 12 ms | 640 KB |
subtask_1_07.txt | AC | 12 ms | 640 KB |
subtask_1_08.txt | AC | 11 ms | 640 KB |
subtask_1_09.txt | AC | 12 ms | 640 KB |
subtask_1_10.txt | AC | 1 ms | 256 KB |
subtask_1_11.txt | AC | 1 ms | 256 KB |