結果
問題 | No.360 増加門松列 |
ユーザー | ぴろず |
提出日時 | 2016-04-17 23:06:31 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 1,320 bytes |
コンパイル時間 | 3,489 ms |
コンパイル使用メモリ | 74,040 KB |
実行使用メモリ | 56,056 KB |
最終ジャッジ日時 | 2023-08-25 18:35:02 |
合計ジャッジ時間 | 7,404 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
55,804 KB |
testcase_01 | AC | 127 ms
55,956 KB |
testcase_02 | AC | 126 ms
55,924 KB |
testcase_03 | AC | 124 ms
56,056 KB |
testcase_04 | AC | 126 ms
55,812 KB |
testcase_05 | AC | 128 ms
53,852 KB |
testcase_06 | AC | 126 ms
53,908 KB |
testcase_07 | AC | 128 ms
55,736 KB |
testcase_08 | AC | 127 ms
55,812 KB |
testcase_09 | AC | 126 ms
55,868 KB |
testcase_10 | AC | 125 ms
55,724 KB |
testcase_11 | AC | 125 ms
55,908 KB |
testcase_12 | AC | 126 ms
55,600 KB |
testcase_13 | AC | 125 ms
55,596 KB |
testcase_14 | AC | 126 ms
55,564 KB |
testcase_15 | AC | 124 ms
55,856 KB |
testcase_16 | AC | 127 ms
55,544 KB |
testcase_17 | AC | 127 ms
55,684 KB |
testcase_18 | AC | 128 ms
55,808 KB |
testcase_19 | AC | 128 ms
55,608 KB |
testcase_20 | AC | 124 ms
55,972 KB |
testcase_21 | AC | 127 ms
55,552 KB |
ソースコード
package no360; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] a = new int[7]; for(int i=0;i<7;i++) { a[i] = sc.nextInt(); } Arrays.sort(a); do { if (isIncreasingKadomatsuSequenceSequence(a)) { System.out.println("YES"); return; } } while(nextPermutation(a)); System.out.println("NO"); } public static boolean isKadomatsuSequence(long a,long b,long c) { if (a == b || b == c || a == c) { return false; } return b < a && b < c || b > a && b > c; } public static boolean isIncreasingKadomatsuSequence(long a,long b,long c) { return a < c && isKadomatsuSequence(a, b, c); } public static boolean isIncreasingKadomatsuSequenceSequence(int[] a) { for(int i=0;i<a.length-2;i++) { if (!isIncreasingKadomatsuSequence(a[i], a[i+1], a[i+2])) { return false; } } return true; } static boolean nextPermutation(int[] p) { for(int a=p.length-2;a>=0;--a) { if(p[a]<p[a+1]) { for(int b=p.length-1;;--b) { if(p[b]>p[a]) { int t = p[a]; p[a] = p[b]; p[b] = t; for(++a, b=p.length-1;a<b;++a,--b) { t = p[a]; p[a] = p[b]; p[b] = t; } return true; } } } } return false; } }