There are $30$ students in a class. In an examination, their results were all different from each other. It is given that everyone has the same number of friends. Find the maximum number of students such that each one of them has a better result than the majority of his friends. 
PS. Here majority means larger than half.
1. **Interpret the problem in terms of graph theory:**
   - We have 30 students, each with a unique result.
   - Each student has the same number of friends.
   - We need to find the maximum number of students who have a better result than the majority of their friends.

2. **Graph Theory Representation:**
   - Represent the students as vertices in a directed graph.
   - An edge from vertex \( u \) to vertex \( v \) indicates that student \( u \) has a better result than student \( v \).
   - Each vertex has the same degree \( d \) (sum of indegree and outdegree).

3. **Definition of Legend Vertices:**
   - A vertex is called a "legend" if its outdegree is strictly greater than its indegree.

4. **Constructing a Graph with 25 Legend Vertices:**
   - Consider a digraph with vertices labeled \( 1, 2, \ldots, 30 \).
   - Construct edges such that there are 25 legend vertices and each vertex has degree 9.
   - Example construction:
     \[
     \begin{aligned}
     &\{6, 7, 8, 9, 10, 11, 12, 13, 14\} \rightarrow \{1, 2, 3, 4, 5\}, \\
     &\{15\} \rightarrow \{6, 7, 8, 9, 10\}, \\
     &\{16\} \rightarrow \{11, 12, 13, 14, 6\}, \\
     &\{17\} \rightarrow \{7, 8, 9, 10, 11\}, \\
     &\{18\} \rightarrow \{12, 13, 14, 6, 7\}, \\
     &\{19\} \rightarrow \{8, 9, 10, 11, 12\}, \\
     &\{20\} \rightarrow \{13, 14, 6, 7, 8\}, \\
     &\{21\} \rightarrow \{9, 10, 11, 12, 13\}, \\
     &\{22\} \rightarrow \{14, 15, 16, 17, 18\}, \\
     &\{23\} \rightarrow \{19, 20, 21, 15, 16\}, \\
     &\{24\} \rightarrow \{17, 18, 19, 26, 21\}, \\
     &\{25\} \rightarrow \{15, 16, 17, 18, 19\}, \\
     &\{26\} \rightarrow \{20, 21, 15, 16, 17\}, \\
     &\{27\} \rightarrow \{18, 19, 20, 21, 22, 23\}, \\
     &\{28\} \rightarrow \{27, 24, 25, 26, 22, 23, 24\}, \\
     &\{29\} \rightarrow \{27, 28, 25, 26, 22, 23, 24, 25\}, \\
     &\{30\} \rightarrow \{27, 28, 29, 26, 22, 23, 24, 25, 20\}.
     \end{aligned}
     \]
   - Verify that this construction results in 25 legend vertices and all vertices have degree 9.

5. **Proving Optimality:**
   - Let \( d \) be the degree of all vertices.
   - **Lemma 1:** The number of legend vertices is at most \( 30 - \left\lceil \frac{d}{2} \right\rceil \).
     - Proof: Students with the lowest \( \left\lceil \frac{d}{2} \right\rceil \) scores cannot be legends.
     - \(\blacksquare\)

6. **Case Analysis on \( d \):**
   - **Case 1: \( d \) is even.**
     - Summing outdegree minus indegree over all vertices:
       \[
       2x - d(30 - x) \leq 0 \implies x \leq \frac{30d}{d + 2}
       \]
     - If \( d \geq 10 \), then \( 30 - \left\lceil \frac{d}{2} \right\rceil \leq 25 \).
     - If \( d \leq 10 \), then \( \frac{30d}{d + 2} \leq 25 \).
     - In either case, there are at most 25 legend vertices.

   - **Case 2: \( d \) is odd.**
     - Define \( x \) similarly, and use the same bounding method:
       \[
       x \leq \frac{30d}{d + 1}
       \]
     - Improved bounding method:
       \[
       \frac{(d + 1)^2}{4} + (d + 1)x \leq 30d + \frac{d + 1}{2} \implies x \leq \frac{30d + \frac{d + 1}{2} - \frac{(d + 1)^2}{4}}{d + 1}
       \]
     - If \( x \geq 9 \), then \( 30 - \left\lceil \frac{d}{2} \right\rceil \leq 25 \).
     - If \( x \leq 9 \), then \( \frac{30d + \frac{d + 1}{2} - \frac{(d + 1)^2}{4}}{d + 1} \leq 25 \).
     - In either case, there are at most 25 legend vertices.

7. **Conclusion:**
   - The maximum number of students such that each one of them has a better result than the majority of their friends is \( \boxed{25} \).