import sequtils,strutils,strscans,algorithm,math,future,sets,queues,tables template get():string = stdin.readLine() template times(n:int,body:untyped): untyped = (for _ in 0..".} [T] = object CPair {.importcpp: "std::pair", header: "".} [T1,T2] = object proc cNewPriorityQueue(T: typedesc): CPriorityQueue[T] {.importcpp: "std::priority_queue<'*1>()", nodecl.} proc cMakePair[T1,T2](t1:T1,t2:T2):CPair[T1,T2] {.importcpp: "std::make_pair(@)", nodecl.} proc first[T1,T2](this: CPair[T1,T2]): T1 {.importcpp: "#.first", nodecl.} proc second[T1,T2](this: CPair[T1,T2]): T2 {.importcpp: "#.second", nodecl.} proc cpop[T](this: CPriorityQueue[T]) {.importcpp: "#.pop(@)", nodecl.} #proc newPriorityQueue*[T](): CPriorityQueue[T] = cNewPriorityQueue(T) proc empty*[T](this:CPriorityQueue[T]):bool {.importcpp: "#.empty(@)", nodecl.} proc size*[T](this:CPriorityQueue[T]):int {.importcpp: "#.size(@)", nodecl.} proc ctop*[T](this: CPriorityQueue[T]):T {.importcpp: "#.top(@)", nodecl.} proc top*[T](this: CPriorityQueue[T]):T {.importcpp: "#.top(@)", nodecl.} proc push*[T](this: CPriorityQueue[T],x:T) {.importcpp: "#.push(@)", nodecl.} proc pop*[T](this:var CPriorityQueue[T]):T =(result = this.top();this.cpop()) proc newPriorityQueue*[T1,T2](): CPriorityQueue[CPair[T1,T2]] = cNewPriorityQueue(CPair[T1,T2]) proc push*[T1,T2](this:var CPriorityQueue[CPair[T1,T2]],x:(T1,T2)): void = this.push(cMakePair(x[0],x[1])) proc pop*[T1,T2](this:var CPriorityQueue[CPair[T1,T2]]):(T1,T2) = let res = this.top();this.cpop();return (res.first,res.second) proc top*[T1,T2](this:var CPriorityQueue[CPair[T1,T2]]):(T1,T2) = let res = this.ctop();return (res.first,res.second) let N = get().parseInt # ~1500 A = get().split().map(parseInt) # my lv B = get().split().map(parseInt) #enemy lv # 一番レベルの低い 一番戦ってないものを戦わせる var resSeq = newSeq[int]() for i in 0..a[1] - b[1])[0][1] * -1 resSeq.add(count) echo resSeq.min