! Try yukicoder ! author: Leonardone @ NEETSDKASU PROGRAM yukicoder INTEGER :: a(7), i, j, k, d(7), f(7), r, b(7), x READ (*,*) a r = 1 DO i = 123456, 6543210 IF (r > 0) THEN DO j = 1, 7 f(j) = 0 END DO r = 0 END IF x = i DO j = 1, 7 k = MOD(x, 10) + 1 x = x / 10 IF (k > 7) exit IF (f(k) > 0) exit f(k) = 1 b(j) = a(k) r = r + 1 END DO IF (r < 7) cycle IF (b(1) >= b(3)) cycle IF (b(2) >= b(4)) cycle IF (b(3) >= b(5)) cycle IF (b(4) >= b(6)) cycle IF (b(5) >= b(7)) cycle IF (b(1) <= b(2) .and. b(2) <= b(3)) cycle IF (b(2) <= b(3) .and. b(3) <= b(4)) cycle IF (b(3) <= b(4) .and. b(4) <= b(5)) cycle IF (b(4) <= b(5) .and. b(5) <= b(6)) cycle IF (b(5) <= b(6) .and. b(6) <= b(7)) cycle PRINT '(A)', 'YES' STOP END DO PRINT '(A)', 'NO' END PROGRAM yukicoder