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