public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         int[] indices = new int[n];
         long[] a = new long[n], b = new long[n];
         for (int i = 0; i < n; i++)
         {
             int r = fs.NextInt(), h = fs.NextInt();
             a[i] = (long)r * r * h;
             indices[i] = i;
         }
         Array.Copy(a, b, n);
         Array.Sort(b);
         for (int i = 0; i < n; i++)
         {
             indices[i] = findValue(b, 0, n - 1, a[i]);
         }
         MaxSegmentTree tree = new MaxSegmentTree(new long[n]);
         for (int i = 0; i < n; i++)
         {
             int index = indices[i];
             long value = tree.QueryMax(0, indices[i] - 1) + a[i];
             tree.Update(indices[i], indices[i], value);
         }
         writer.WriteLine((tree.QueryMax(0, n - 1) * Math.PI).ToString().Replace(',', '.'));
     }
 }
Example #2
0
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
         using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
         {
             int    n       = fs.NextInt();
             int[]  indices = new int[n];
             long[] a       = new long[n], b = new long[n];
             for (int i = 0; i < n; i++)
             {
                 int r = fs.NextInt(), h = fs.NextInt();
                 a[i]       = (long)r * r * h;
                 indices[i] = i;
             }
             Array.Copy(a, b, n);
             Array.Sort(b);
             for (int i = 0; i < n; i++)
             {
                 indices[i] = findValue(b, 0, n - 1, a[i]);
             }
             MaxSegmentTree tree = new MaxSegmentTree(new long[n]);
             for (int i = 0; i < n; i++)
             {
                 int  index = indices[i];
                 long value = tree.QueryMax(0, indices[i] - 1) + a[i];
                 tree.Update(indices[i], indices[i], value);
             }
             writer.WriteLine((tree.QueryMax(0, n - 1) * Math.PI).ToString().Replace(',', '.'));
         }
 }
Example #3
0
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
         using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
         {
             int            n    = fs.NextInt();
             double[]       vols = new double[n];
             int[]          inds = new int[n];
             MaxSegmentTree tree = new MaxSegmentTree(new double[n]);
             for (int i = 0; i < n; i++)
             {
                 inds[i] = i;
                 double r = fs.NextInt(), h = fs.NextInt();
                 vols[i] = r * r * h;
             }
             Array.Sort(vols, inds);
             List <Update> list = new List <Update>();
             for (int i = 0; i < n; i++)
             {
                 if (i > 0 && vols[i] != vols[i - 1])
                 {
                     foreach (Update u in list)
                     {
                         tree.Update(u.Index, u.Index, u.Value);
                     }
                     list.Clear();
                 }
                 int    index = inds[i];
                 double value = inds[i] == 0 ? vols[i] : tree.QueryMax(0, inds[i] - 1) + vols[i];
                 list.Add(new Update {
                     Index = index, Value = value
                 });
             }
             foreach (Update u in list)
             {
                 tree.Update(u.Index, u.Index, u.Value);
             }
             writer.WriteLine((tree.QueryMax(0, n - 1) * Math.PI).ToString().Replace(",", "."));
         }
 }
 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         double[] vols = new double[n];
         int[] inds = new int[n];
         MaxSegmentTree tree = new MaxSegmentTree(new double[n]);
         for (int i = 0; i < n; i++)
         {
             inds[i] = i;
             double r = fs.NextInt(), h = fs.NextInt();
             vols[i] = r * r * h;
         }
         Array.Sort(vols, inds);
         List<Update> list = new List<Update>();
         for (int i = 0; i < n; i++)
         {
             if (i > 0 && vols[i] != vols[i - 1])
             {
                 foreach (Update u in list)
                 {
                     tree.Update(u.Index, u.Index, u.Value);
                 }
                 list.Clear();
             }
             int index = inds[i];
             double value = inds[i] == 0 ? vols[i] : tree.QueryMax(0, inds[i] - 1) + vols[i];
             list.Add(new Update { Index = index, Value = value });
         }
         foreach (Update u in list)
         {
             tree.Update(u.Index, u.Index, u.Value);
         }
         writer.WriteLine((tree.QueryMax(0, n - 1) * Math.PI).ToString().Replace(",", "."));
     }
 }