Submission #1220987
Source Code Expand
#include <cstdio> #include <cstring> #include <cassert> #include <algorithm> #include <iostream> #include <vector> using namespace std; #define TRACE(x) cerr << #x << " = " << x << endl #define REP(i, n) for (int i=0; i<n; i++) #define FOR(i, a, b) for (int i=(a); i<(b); i++) #define _ << " " << typedef long long ll; typedef pair<int, int> P; #define X first #define Y second const int MAX = 1<<17; int n, p[MAX]; int main() { scanf("%d", &n); REP(i, n) scanf("%d", &p[i]); int rje = 0; for (int i=0; i<n; ) { int j = i+1, st = -1; for (; j<n; j++) { if (p[j] != p[j-1]) { int nst = p[j] > p[j-1]; if (st == -1) st = nst; else if (st != nst) { break; } } } i = j; rje++; } printf("%d\n", rje); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | dbradac |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 818 Byte |
Status | AC |
Exec Time | 13 ms |
Memory | 640 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:26:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:27:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] REP(i, n) scanf("%d", &p[i]); ^
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 | 256 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 | 384 KB |
subtask_1_03.txt | AC | 4 ms | 384 KB |
subtask_1_04.txt | AC | 13 ms | 640 KB |
subtask_1_05.txt | AC | 12 ms | 640 KB |
subtask_1_06.txt | AC | 13 ms | 640 KB |
subtask_1_07.txt | AC | 13 ms | 640 KB |
subtask_1_08.txt | AC | 12 ms | 640 KB |
subtask_1_09.txt | AC | 13 ms | 640 KB |
subtask_1_10.txt | AC | 1 ms | 256 KB |
subtask_1_11.txt | AC | 1 ms | 256 KB |