! Try yukicoder ! author: Leonardone @ NEETSDKASU PROGRAM yukicoder INTEGER :: a(7), i, j, k, x(7), d(7), f(7), r, b(7) READ (*,*) a DO j = 0, 6 x(j + 1) = 10 ** j END DO r = 1 DO i = 123456, 6543210 IF (r > 0) THEN DO j = 1, 7 f(j) = 0 END DO r = 0 END IF DO j = 0, 6 k = MOD(i / x(j), 10) + 1 IF (k > 7) exit IF (f(k) > 0) exit f(k) = 1 b(j + 1) = 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