1. Given the set $S=\{1,2, \cdots, 3 n\}, n$ is a positive integer, $T$ is a subset of $S$, satisfying: for any $x, y, z \in T$ (where $x, y, z$ can be the same), we have $x+y+z \notin T$. Find the maximum number of elements in all such sets $T$.
1. If we take $T_{0}=\{n+1, n+2, \cdots, 3 n\}$, then $\left|T_{0}\right|=2 n$, and the sum of any three numbers in $T_{0}$ is greater than $3 n$, i.e., not in $T_{0}$. Therefore, $\max |T| \geqslant 2 n$.
On the other hand, consider the sequence of three-element subsets
$A_{0}=\{n, 2 n, 3 n\}$,
$A_{k}=\{k, 2 n-k, 2 n+k\}(k=1,2, \cdots, n-1)$.
Then $S=\bigcup_{k=0}^{n-1} A_{k}$.
For any $(2 n+1)$-element subset $T^{\prime}$ of $S$, it must contain some $A_{k}$.
If $A_{0} \subset T$, then it contains the element $3 n=n+n+n$;
If some $A_{k} \subset T^{\prime}(k \in\{1,2, \cdots, n-1\})$, then it contains the element $2 n+k=k+k+(2 n-k)$.
Thus, $\max |T|<2 n+1$.
Therefore, $\max |T|=2 n$.