NIKKEI Programming Contest 2019-2 Task E. Non-triangular Triplets
此必要条件也可用另一种方法推导出来:
由于 $\sum_{i = 1}^{N} (a_i + b_i) \ge \sum_{i=K}^{K+2N-1} i $ 且 \(\sum_{i=1}^{N} c_i \le \sum_{i = K+2N}^{K+3N-1} i\),因此 \(\sum_{i = 1}^{N} (a_i + b_i) \le \sum_{i=1}^{N} c_i \implies \sum_{i=K}^{K+2N-1} i \le \sum_{i = K+2N}^{K+3N-1} i \implies 2K - 1\le N\)。
构造
the pattern is \((x, y)\), \((x+2, y -1)\), ...
例子
\(K = 2, N = 6\)
\begin{matrix}
3 & 5 & \enclose{right}{7} & 2 & 4 & 6 \\
10 & 9 & \enclose{right}{8} & 13 &12 & 11 \\
\hline
14 & 15 & 16 & 17 & 18 & 19
\end{matrix}
\(K = 2, N = 7\)
\begin{matrix}
2 & 4 & 6 & 8 & 3 & 5 & 7 \\
15 & 14 & 13 & 12 & 11 & 10 & 9 \\
\hline
19 & 20 & 21 & 22 & 16 & 17 & 18
\end{matrix}