美团8.20笔试第二为啥卡91%?
import java.util.*; public class Main { public static void main(String[] args) { Main main = new Main(); Scanner in = new Scanner(System.in); int n = in.nextInt(); int x1 = in.nextInt(); int y1 = in.nextInt(); int x2 = in.nextInt(); int y2 = in.nextInt(); int x3 = in.nextInt(); int y3 = in.nextInt(); int dis1 = in.nextInt(); int dis2 = in.nextInt(); int dis3 = in.nextInt(); Set<String> a1 = new HashSet<>(); Set<String> a2 = new HashSet<>(); Set<String> a3 = new HashSet<>(); List<String> result = new ArrayList<>(); for(int i = 1;i<=n;i++){ int tempA = Math.abs(x1-i); int tempB = 0; if(dis1 - tempA >=0) { tempB = y1 - (dis1 - tempA); if(tempB>=1) a1.add(i+" "+tempB); tempB = y1 + (dis1-tempA); if(tempB<=n) a1.add(i+" "+tempB); } tempA = Math.abs(x2-i); if(dis2 - tempA >=0) { tempB = y2 - (dis2 - tempA); if(tempB>=1) a2.add(i+" "+tempB); tempB = y2 + (dis2 - tempA); if(tempB<=n) a2.add(i+" "+tempB); } tempA = Math.abs(x3-i); if(dis3 - tempA >=0) { tempB = y3 - (dis3 - tempA); if(tempB>=1) a3.add(i+" "+tempB); tempB = y3 + (dis3-tempA); if(tempB<=n) a3.add(i+" "+tempB); } } for(String target : a1) { if(a2.contains(target)&&a3.contains(target)) { result.add(target); } } Collections.sort(result); System.out.println(result.get(0)); } }
#美团笔试##美团##做完美团2023秋招笔试,你还好吗#