using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ Pair[] P = new Pair[N]; Dictionary dic = new Dictionary(); for(int i=0;i -p.D.CompareTo(q.D)); bool[] forbid = new bool[N]; for(int i=0;i=0 && T[idx] - T[j] < K){ forbid[j] = true; j--; } j = idx; while(j= yukiMin)continue; ameMax = Math.Max(ameMax,D[i]); } long yukiDo = 0; bool[] used = new bool[N]; forbid = new bool[N]; for(int i=0;i= yukiMin){ used[i] = true; int j=i-1; while(j>=0 && T[i] - T[j] < K){ forbid[j] = true; j--; } yukiDo += D[i]; } } //Console.WriteLine("forbid:{0}",String.Join(" ",forbid)); //Console.WriteLine("used :{0}",String.Join(" ",used)); int[] nxt = new int[N]; int nn=0; for(int i=0;iint.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }