Submission #1221355
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < int(n); ++i) #define REPE(i, a, b) for (int i = (a); i <= int(b); ++i) #define SZ(x) ((int)(x).size()) #define ALL(x) x.begin(), x.end() #define PB push_back #define EB emplace_back using LL = long long; using PII = pair<int, int>; #define F first #define S second int n, a[100010]; int main() { scanf("%d", &n); REP(i, n) scanf("%d", &a[i]); int ans = 0; for (int i = 0; i < n;) { ans++; int cur = 0; int j = i + 1; while (j < n) { int v = 0; if (a[j] != a[j - 1]) { v = a[j] > a[j - 1] ? 1 : -1; } if (cur == v || cur == 0 || v == 0) { if (cur == 0) cur = v; j++; } else break; } i = j; } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | cchao |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 849 Byte |
Status | AC |
Exec Time | 13 ms |
Memory | 640 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:17:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:18:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] REP(i, n) scanf("%d", &a[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 | 7 ms | 384 KB |
subtask_1_03.txt | AC | 5 ms | 384 KB |
subtask_1_04.txt | AC | 13 ms | 640 KB |
subtask_1_05.txt | AC | 13 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 | 13 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 |