TopCoder SRM582: ShoutterDiv2
全探索。
クエリ式を使うと作業用ローカル変数が減って、幸せな気持ちになれます。
public class ShoutterDiv2 { public int count(int[] s, int[] t) { int n = s.Length; return (from i in Enumerable.Range(0, n) from j in Enumerable.Range(0, n) where i < j && Math.Max(s[i], s[j]) <= Math.Min(t[i], t[j]) select 1).Sum(); } }