Created
June 2, 2021 02:01
-
-
Save sakapon/4fac283c1589fb67ee182c8360f2a16c to your computer and use it in GitHub Desktop.
競プロ典型 90 問 / Q036
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
class Q036 | |
{ | |
static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse); | |
static (int x, int y) Read2() { var a = Read(); return (a[0], a[1]); } | |
static void Main() => Console.WriteLine(Solve()); | |
static object Solve() | |
{ | |
var (n, qc) = Read2(); | |
var ps = Array.ConvertAll(new bool[n], _ => Read2()); | |
var qs = Array.ConvertAll(new bool[qc], _ => int.Parse(Console.ReadLine())); | |
var xy1 = Array.ConvertAll(ps, p => p.x + p.y); | |
var xy2 = Array.ConvertAll(ps, p => p.x - p.y); | |
long max1 = xy1.Max(); | |
long min1 = xy1.Min(); | |
long max2 = xy2.Max(); | |
long min2 = xy2.Min(); | |
long Query(int i) | |
{ | |
var d1 = Math.Max(max1 - xy1[i], xy1[i] - min1); | |
var d2 = Math.Max(max2 - xy2[i], xy2[i] - min2); | |
return Math.Max(d1, d2); | |
} | |
return string.Join("\n", qs.Select(q => Query(q - 1))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://atcoder.jp/contests/typical90/submissions/22566441