Submission #1306692
Source Code Expand
import java.io.*; import java.math.*; import java.util.*; public class Main { private static boolean debug = false; private static boolean elapsed = false; private static PrintWriter _out = new PrintWriter(System.out); private static PrintWriter _err = new PrintWriter(System.err); private void solve(Scanner sc) { int N = sc.nextInt(); int[] A = new int[N]; int ans = 0; for (int i = 0; i < N; ++i) { A[i] = sc.nextInt(); } for (int i = 0; i < N; ++i) { if (i > 0) { if (A[i - 1] < A[i]) { while (i < N && A[i - 1] <= A[i]) { ++i; } if (i < N) { ++ans; } } else if (A[i - 1] > A[i]) { while (i < N && A[i - 1] >= A[i]) { ++i; } if (i < N) { ++ans; } } else { while (i < N && A[i - 1] == A[i]) { ++i; } } } else { ++ans; } } _out.println(ans); } private static BigInteger C(long n, long r) { BigInteger res = BigInteger.ONE; for (long i = n; i > n - r; --i) { res = res.multiply(BigInteger.valueOf(i)); } for (long i = r; i > 1; --i) { res = res.divide(BigInteger.valueOf(i)); } return res; } private static BigInteger P(long n, long r) { BigInteger res = BigInteger.ONE; for (long i = n; i > n - r; --i) { res = res.multiply(BigInteger.valueOf(i)); } return res; } /* * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9 * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18 */ public static void main(String[] args) { long S = System.currentTimeMillis(); Scanner sc = new Scanner(System.in); new Main().solve(sc); _out.flush(); long G = System.currentTimeMillis(); if (elapsed) { _err.println((G - S) + "ms"); } _err.flush(); } }
Submission Info
Submission Time | |
---|---|
Task | A - Sorted Arrays |
User | hhelibex |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 2385 Byte |
Status | WA |
Exec Time | 460 ms |
Memory | 50800 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 | 92 ms | 18900 KB |
sample_02.txt | AC | 91 ms | 20692 KB |
sample_03.txt | AC | 92 ms | 19284 KB |
subtask_1_01.txt | AC | 384 ms | 46176 KB |
subtask_1_02.txt | AC | 354 ms | 43524 KB |
subtask_1_03.txt | AC | 302 ms | 42048 KB |
subtask_1_04.txt | AC | 456 ms | 48520 KB |
subtask_1_05.txt | AC | 430 ms | 50788 KB |
subtask_1_06.txt | AC | 445 ms | 47692 KB |
subtask_1_07.txt | WA | 460 ms | 48744 KB |
subtask_1_08.txt | AC | 430 ms | 50800 KB |
subtask_1_09.txt | WA | 446 ms | 48668 KB |
subtask_1_10.txt | AC | 92 ms | 21076 KB |
subtask_1_11.txt | AC | 92 ms | 20820 KB |