Proof. The algorithm first stores missing = S . During the input loop it subtracts each read number a_j from missing . After the loop finishes
Proof. All numbers of {1,…,N+1} appear either in T (if they are present) or are the missing value m . Hence 354. Missax
(Typical “find the missing element” problem – often appears on many online judges under the name Missax .) 1. Problem statement You are given an integer N ( 1 ≤ N ≤ 10⁶ ) . Then N distinct integers a₁ , a₂ , … , a_N are supplied. After the loop finishes Proof
All the numbers belong to the set
Proof. By Lemma 2 the value stored in missing after processing the whole test case equals S – T . By Lemma 1 S – T equals the missing element m . Therefore the printed value is exactly m . ∎ Time – each number is read and processed once → O(N) per test case. Memory – only a few 64‑bit variables are kept → O(1) . 6. Reference implementation (C++17) #include <bits/stdc++.h> using namespace std; Problem statement You are given an integer N
The input may contain several test cases. Each test case is described as follows