using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; 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));} } class BIT{ int MM; int n; long[] bit; public BIT(int n_){ n=n_; MM=1<<18; while(MMsum(a_1,...,a_i) // i=0 -> return 0; public long Sum(int i){ long s=0; while(i>0){ s+=bit[i]; i-= (i&-i); } return s; } }