Submission #2240099
Source Code Expand
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] a = new int[n], b = new int[n]; int[] c = new int[m], d = new int[m]; for(int i = 0; i < n; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); } for(int j = 0; j < m; j++) { c[j] = sc.nextInt(); d[j] = sc.nextInt(); } int dist, min_dist, checkpoint; for(int i = 0; i < n; i++) { min_dist = Math.abs(a[i] - c[0]) + Math.abs(b[i] - d[0]); checkpoint = 0; for(int j = 1; j < m; j++) { dist = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]); if(dist < min_dist) { min_dist = dist; checkpoint = j; } } System.out.println(checkpoint + 1); } } }
Submission Info
Submission Time | |
---|---|
Task | B - Checkpoints |
User | kobana0 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 807 Byte |
Status | AC |
Exec Time | 105 ms |
Memory | 21844 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 91 ms | 18516 KB |
sample_02.txt | AC | 91 ms | 19924 KB |
sample_03.txt | AC | 94 ms | 19156 KB |
subtask_1_1.txt | AC | 99 ms | 19924 KB |
subtask_1_2.txt | AC | 102 ms | 18388 KB |
subtask_1_3.txt | AC | 99 ms | 21844 KB |
subtask_1_4.txt | AC | 96 ms | 19796 KB |
subtask_1_5.txt | AC | 100 ms | 18644 KB |
subtask_1_6.txt | AC | 99 ms | 21844 KB |
subtask_1_7.txt | AC | 105 ms | 21204 KB |