fork(10) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. long numberOfTests = 0;
  8. string[] inputData;
  9. long[,] pointsData;
  10. double[] area = new double[2];
  11. //double area2 = 0;
  12. int inkForBlackArea = 5; // 10;
  13. int inkForGreyArea = 3; // 6;
  14. double[] inkUsed;
  15.  
  16. numberOfTests = long.Parse(Console.ReadLine());
  17. inkUsed = new double[numberOfTests];
  18.  
  19. for (long i = 0; i < numberOfTests; i++)
  20. {
  21. for (int n = 0; n < 2; n++)
  22. {
  23. // Prepare data for calculation area.
  24. inputData = Console.ReadLine().Split(new char[] {' ', '\t'});
  25. pointsData = new long[inputData.Length / 2, 2];
  26. for (int j = 0; j < inputData.Length / 2; j++)
  27. {
  28. pointsData[j, 0] = long.Parse(inputData[j * 2]);
  29. pointsData[j, 1] = long.Parse(inputData[j * 2 + 1]);
  30. }
  31. // Calculate first area.
  32. for (int j = 0; j < inputData.Length / 2 - 1; j++)
  33. {
  34. //area[n] = area[n] + (pointsData[j, 0] + pointsData[j + 1, 0]) * (pointsData[j + 1, 1] - pointsData[j, 1]);
  35. area[n] = area[n] + (pointsData[j, 0] * pointsData[j + 1, 1]) - (pointsData[j + 1, 0] * pointsData[j, 1]);
  36. }
  37. area[n] = Math.Abs(area[n]);
  38. }
  39.  
  40. // Calculate ink used for drawing.
  41. if (area[1] >= area[0])
  42. {
  43. area[1] -= area[0];
  44. inkUsed[i] = (double)(area[0] * inkForBlackArea + area[1] * inkForGreyArea);
  45. }
  46. else
  47. {
  48. area[0] -= area[1];
  49. inkUsed[i] = (double)(area[1] * inkForBlackArea + area[0] * inkForGreyArea);
  50. }
  51. //Prepare for next test
  52. //Console.ReadLine();
  53. area[0] = 0;
  54. area[1] = 0;
  55. }
  56. for (long i = 0; i < numberOfTests; i++)
  57. {
  58. Console.WriteLine(inkUsed[i]);
  59. }
  60. }
  61. }
Success #stdin #stdout 0.01s 131072KB
stdin
16
5 4 3 8 9 2 2 5 -3 2 6 -4 3 -2 1 9 -9 -4 4 4 -4 3 -1 -5 -6 4 3 0 2 1 9 4 2 0 3 -4 5 4
9 3 0 4 -3 2 5 -6 3 -4 7 6 -3 2 7 -6 8 4 3 -6 9 4 -5 9 1 -1 9 4 7 2 -5 2 7 -8 -3 2 -2 1 0 4 0 5 6 -3 9 3
3634 346 35 346 34 346 34 634543 34634 346 43 346346 87 3 903463 34 34 34632 6346 25626 34578 7894 4326 4372 65357 23632 67432 76321 67622 356 3634 346
89540 34530 349 345 3045 4603 9343 -4563 -435 3423 2343 -3456 353 -3235 -8765 2345 -6322 225 -551525 3632 -62523 63252 -5526 65252 -63236 6332 89540 34530
89540 34530 349 345 3045 4603 9343 -4563 -435 3423 2343 -3456 353 -3235 -8765 2345 -6322 225 -551525 3632 -62523 63252 -5526 65252 -63236 6332 89540 34530
3634 346 35 346 34 346 34 634543 34634 346 43 346346 87 3 903463 34 34 34632 6346 25626 34578 7894 4326 4372 65357 23632 67432 76321 67622 356 3634 346
5 6 7 8 3 -5 2 -6 3 5 5 6
-5 -6 -7 -8 -3 5 -2 6 -3 -5 -5 -6
5 -3 1 4 -6 2 06 3 -2 9 5 -3
6 3 6 2 9 4 6 -2 7 -3 4 0 6 3
09 -05 3 9 04 5 03 5 014 4 5 2 345 23 2 -03 09 -05
9 4 -3 5 -3 43 -53 -3433 35 3 4 -5 -03 2 -2 -5 -4 2 -6 0 9 4
1 7 9 3 1 7
1 7 9 3 1 7
0 5 3 1 5 2 6 9 0 3 6 6 0 5
9 4 3 -7 -2 7 7 4 -6 -7 3 -2 -6 0 9 3 9 4
1 1 1 1
0 5 3 1 5 2 6 9 0 3 6 6 0 5
1 9 1 9
9 4 9 4
5 3 4 5 5 4 6 5 5 3
8 8 6 4 8 0 5 3 2 0 4 4 2 8 5 5 8 8
-1 1 0 0 1 1 0 -1 -1 1
-3 4 0 1 3 4 1 0 3 -4 0 -1 -3 -4 -1 0 -3 4
50000 30000 40000 50000 50000 40000 60000 50000 50000 30000
80000 80000 60000 40000 80000 0 50000 30000 20000 0 40000 40000 20000 80000 50000 50000 80000 80000
-10000 10000 0 0 10000 10000 0 -10000 -10000 10000
-30000 40000 0 10000 30000 40000 10000 0 30000 -40000 0 -10000 -30000 -40000 -10000 0 -30000 40000
8 8 6 4 8 0 5 3 2 0 4 4 2 8 5 5 8 8
5 3 4 5 5 4 6 5 5 3
-3 4 0 1 3 4 1 0 3 -4 0 -1 -3 -4 -1 0 -3 4
-1 1 0 0 1 1 0 -1 -1 1
stdout
1360
147855197000
147855197000
240
164
400136
0
512
147
0
88
88
8800000000
8800000000
88
88