/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 77ms 37.664 MiB
#2 Accepted 76ms 37.461 MiB
#3 Accepted 77ms 37.438 MiB
#4 Accepted 78ms 37.652 MiB
#5 Accepted 75ms 37.613 MiB
#6 Accepted 76ms 37.5 MiB
#7 Accepted 76ms 37.582 MiB
#8 Accepted 76ms 37.559 MiB
#9 Accepted 78ms 37.527 MiB
#10 Accepted 75ms 37.504 MiB
#11 Accepted 75ms 37.496 MiB
#12 Accepted 75ms 37.66 MiB
#13 Accepted 76ms 37.496 MiB
#14 Accepted 76ms 37.602 MiB
#15 Accepted 76ms 37.59 MiB
#16 Accepted 78ms 37.629 MiB
#17 Accepted 77ms 37.5 MiB
#18 Accepted 77ms 37.543 MiB
#19 Accepted 78ms 37.469 MiB
#20 Accepted 77ms 37.547 MiB
#21 Accepted 77ms 37.5 MiB
#22 Accepted 77ms 37.5 MiB
#23 Accepted 77ms 37.512 MiB
#24 Accepted 77ms 37.625 MiB
#25 Accepted 78ms 37.52 MiB
#26 Accepted 76ms 37.711 MiB
#27 Accepted 78ms 37.648 MiB
#28 Accepted 76ms 37.555 MiB
#29 Accepted 76ms 37.648 MiB
#30 Accepted 78ms 37.496 MiB
#31 Accepted 79ms 37.469 MiB
#32 Accepted 79ms 37.547 MiB
#33 Accepted 79ms 37.73 MiB
#34 Accepted 79ms 37.504 MiB
#35 Accepted 79ms 37.562 MiB
#36 Accepted 79ms 37.555 MiB
#37 Accepted 83ms 37.816 MiB
#38 Accepted 80ms 37.523 MiB
#39 Accepted 81ms 37.469 MiB
#40 Accepted 81ms 37.625 MiB
#41 Accepted 90ms 37.5 MiB
#42 Accepted 139ms 37.695 MiB
#43 Accepted 137ms 37.648 MiB
#44 Accepted 86ms 37.715 MiB
#45 Accepted 87ms 37.734 MiB
#46 Accepted 87ms 37.5 MiB
#47 Accepted 86ms 37.699 MiB
#48 Accepted 85ms 37.5 MiB
#49 Accepted 88ms 37.699 MiB
#50 Accepted 86ms 37.527 MiB
#51 Accepted 89ms 37.57 MiB
#52 Accepted 85ms 37.5 MiB
#53 Accepted 85ms 37.605 MiB
#54 Accepted 86ms 37.66 MiB
#55 Accepted 87ms 37.652 MiB
#56 Accepted 88ms 37.586 MiB
#57 Accepted 87ms 37.777 MiB
#58 Accepted 85ms 37.5 MiB
#59 Accepted 88ms 37.656 MiB
#60 Accepted 84ms 37.5 MiB
#61 Accepted 119ms 39.18 MiB
#62 Accepted 98ms 38.465 MiB
#63 Accepted 99ms 38.598 MiB
#64 Accepted 104ms 38.531 MiB
#65 Accepted 102ms 38.398 MiB
#66 Accepted 109ms 38.496 MiB
#67 Accepted 102ms 38.848 MiB
#68 Accepted 104ms 38.484 MiB
#69 Accepted 111ms 38.633 MiB
#70 Accepted 100ms 38.523 MiB
#71 Accepted 131ms 39.031 MiB
#72 Accepted 101ms 39.223 MiB
#73 Accepted 103ms 38.996 MiB
#74 Accepted 113ms 39.211 MiB
#75 Accepted 110ms 38.641 MiB
#76 Accepted 115ms 38.676 MiB
#77 Accepted 104ms 39.281 MiB
#78 Accepted 108ms 38.93 MiB
#79 Accepted 115ms 38.906 MiB
#80 Accepted 101ms 39.043 MiB
#81 Accepted 140ms 39.203 MiB
#82 Accepted 103ms 39.605 MiB
#83 Accepted 109ms 39.562 MiB
#84 Accepted 119ms 39.777 MiB
#85 Accepted 114ms 38.484 MiB
#86 Accepted 113ms 39.031 MiB
#87 Accepted 105ms 39.578 MiB
#88 Accepted 110ms 39.734 MiB
#89 Accepted 121ms 39.406 MiB
#90 Accepted 103ms 39.641 MiB
#91 Accepted 994ms 57.777 MiB
#92 Accepted 173ms 55.414 MiB
#93 Accepted 182ms 55.785 MiB
#94 Accepted 968ms 54.984 MiB
#95 Accepted 930ms 47.625 MiB
#96 Accepted 542ms 52.445 MiB
#97 Accepted 189ms 56.543 MiB
#98 Accepted 184ms 54.949 MiB
#99 Accepted 520ms 54.059 MiB
#100 Accepted 171ms 55.227 MiB

Code

from collections import *        # Useful for deque, Counter, defaultdict, namedtuple, etc.
from itertools import *          # Provides tools for combinations, permutations, product, etc.
from functools import *          # Includes tools like lru_cache for memoization, reduce, etc.
from heapq import *              # Provides heap operations like heappush, heappop, useful for priority queues
from bisect import *             # For efficient binary search and maintaining sorted lists
from math import *               # Includes functions like gcd, sqrt, factorial, isqrt, comb, etc.
from operator import *           # Includes functions like itemgetter, attrgetter, add, mul for functional programming
from array import *              # For efficient storage and manipulation of numeric arrays
from typing import *             # Provides typing hints (List, Tuple, Dict, etc.) to improve readability and error-checking
from decimal import *            # High-precision arithmetic operations, useful for certain precision tasks
from queue import *              # Includes Queue, LifoQueue, PriorityQueue useful in BFS, DFS, and other algorithms
import sys
sys.setrecursionlimit(10**5)
def POW(base, exp, mod):
    result = 1
    base = base % mod  # Handle case when base is larger than mod
    while exp > 0:
        if exp % 2 == 1:  # If exp is odd, multiply base with result
            result = (result * base) % mod
        exp = exp // 2    # Divide exp by 2
        base = (base * base) % mod  # Square the base
    return result
def IL():
  return [int(i) for i in input().split()]
def CL():
  return [i for i in input().split()]
def I():
  return input()
def inti():
  return int(input())
def db(x):
  return print(x)
def dbl(x):
  return print(*x)
def dbm(x):
  for i in x:
    print(i)
def sq(x):
  return x==int(x**0.5)**2
def prime(n):
    if n <= 1:
        return False
    if n <= 3:
        return True
    if (n & 1) == 0 or n % 3 == 0:
        return False
    i = 5
    while i * i <= n:
        if n % i == 0 or n % (i + 2) == 0:
            return False
        i += 6
    return True

char="abcdefghijklmnopqrstuvwxyz"
mod=pow(10,9)+7


n=inti()
arr=IL()
back1=[]
ans=set()
for i in range(n):
    cnt=bisect_right(back1, arr[i])
    if cnt>=arr[i]:
      ans.add(i)
    insort(back1, arr[i])  
back2=[]
for i in range(n-1,-1,-1):
    cnt=len(back2)-bisect_left(back2,arr[i])
    if cnt>=arr[i]:
      ans.add(i)
    insort(back2,arr[i])
print(len(ans))

Information

Submit By
Type
Submission
Problem
P1184 The Curious Kid and the Number Game
Contest
Brain Booster #9
Language
PyPy 3 (Python 3.9.18 PyPy 7.3.15)
Submit At
2025-04-06 16:10:59
Judged At
2025-04-06 16:10:59
Judged By
Score
100
Total Time
994ms
Peak Memory
57.777 MiB