Submission #7273701


Source Code Expand

Copy
n = read_line.to_i
vs = Array.new(n) { read_line.split.map(&.to_i64) }
printf("%.10f\n", vs.map do |v|
  {solve(v[0], v[1], vs), solve(v[1], -v[0], vs)}.max
end.max)

def solve(bx, by, vs)
  {solve_(bx, by, vs),
   solve_(-bx, -by, vs),
   solve_(bx*0.99 + by * 0.01, by * 0.99 + bx * 0.01, vs),
   solve_(bx*0.99 - by * 0.01, by * 0.99 - bx * 0.01, vs),
  }.max
end

def solve_(bx, by, vs)
  sx = 0i64
  sy = 0i64
  vs.each do |v|
    if 0 < v[0] * bx + v[1] * by
      sx += v[0]
      sy += v[1]
    end
  end
  (sx * sx + sy * sy) ** 0.5
end

Submission Info

Submission Time
Task F - Engines
User tomerun
Language Crystal (0.20.5)
Score 600
Code Size 571 Byte
Status AC
Exec Time 6 ms
Memory 2556 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 7
AC × 41
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 00-sample-04.txt, 00-sample-05.txt, 00-sample-06.txt, 00-sample-07.txt
All 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 00-sample-04.txt, 00-sample-05.txt, 00-sample-06.txt, 00-sample-07.txt, 01-random-very-small-01.txt, 01-random-very-small-02.txt, 01-random-very-small-03.txt, 02-random-small-01.txt, 02-random-small-02.txt, 02-random-small-03.txt, 03-random-01.txt, 03-random-02.txt, 03-random-03.txt, 04-zero-01.txt, 05-same-01.txt, 05-same-02.txt, 06-linear-01.txt, 06-linear-02.txt, 06-linear-03.txt, 07-linear-positive-01.txt, 07-linear-positive-02.txt, 07-linear-positive-03.txt, 08-90-degree-01.txt, 08-90-degree-02.txt, 09-180-degree-01.txt, 09-180-degree-02.txt, 10-sandglass-01.txt, 10-sandglass-02.txt, 11-circle-01.txt, 11-circle-02.txt, 11-circle-03.txt, 11-circle-04.txt, 11-circle-05.txt, 12-square-01.txt, 12-square-02.txt, 12-square-03.txt, 13-corner-01.txt, 13-corner-02.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 2 ms 636 KB
00-sample-02.txt AC 2 ms 636 KB
00-sample-03.txt AC 2 ms 636 KB
00-sample-04.txt AC 2 ms 636 KB
00-sample-05.txt AC 2 ms 636 KB
00-sample-06.txt AC 2 ms 636 KB
00-sample-07.txt AC 2 ms 764 KB
01-random-very-small-01.txt AC 2 ms 636 KB
01-random-very-small-02.txt AC 5 ms 636 KB
01-random-very-small-03.txt AC 6 ms 636 KB
02-random-small-01.txt AC 2 ms 636 KB
02-random-small-02.txt AC 6 ms 2556 KB
02-random-small-03.txt AC 6 ms 636 KB
03-random-01.txt AC 2 ms 636 KB
03-random-02.txt AC 6 ms 636 KB
03-random-03.txt AC 6 ms 636 KB
04-zero-01.txt AC 4 ms 636 KB
05-same-01.txt AC 3 ms 2556 KB
05-same-02.txt AC 6 ms 2556 KB
06-linear-01.txt AC 2 ms 636 KB
06-linear-02.txt AC 3 ms 636 KB
06-linear-03.txt AC 6 ms 636 KB
07-linear-positive-01.txt AC 3 ms 2556 KB
07-linear-positive-02.txt AC 3 ms 636 KB
07-linear-positive-03.txt AC 6 ms 636 KB
08-90-degree-01.txt AC 5 ms 636 KB
08-90-degree-02.txt AC 6 ms 636 KB
09-180-degree-01.txt AC 4 ms 636 KB
09-180-degree-02.txt AC 6 ms 636 KB
10-sandglass-01.txt AC 3 ms 636 KB
10-sandglass-02.txt AC 6 ms 636 KB
11-circle-01.txt AC 2 ms 636 KB
11-circle-02.txt AC 2 ms 636 KB
11-circle-03.txt AC 2 ms 636 KB
11-circle-04.txt AC 3 ms 636 KB
11-circle-05.txt AC 5 ms 636 KB
12-square-01.txt AC 4 ms 636 KB
12-square-02.txt AC 5 ms 636 KB
12-square-03.txt AC 6 ms 636 KB
13-corner-01.txt AC 2 ms 636 KB
13-corner-02.txt AC 2 ms 2556 KB