提出 #32380836
ソースコード 拡げる
import java.io.*;
import java.util.*;
public class Main{
static void main() throws Exception{
int n=sc.nextInt(),k=sc.nextInt();
boolean[]has=new boolean[n];
for(int i=0;i<k;i++)has[sc.nextInt()-1]=true;
int[][]in=new int[n][];
for(int i=0;i<n;i++)in[i]=sc.intArr(2);
long lo=0,hi=(500000l)*(500000l);
long ans=hi;
while(lo<=hi){
long mid=(lo+hi)>>1;
boolean[]ok=new boolean[n];
int cnt=0;
for(int i=0;i<n;i++){
if(!has[i])continue;
for(int j=0;j<n;j++){
long dist=(in[i][0]-in[j][0])*1l*(in[i][0]-in[j][0])+(in[i][1]-in[j][1])*1l*(in[i][1]-in[j][1]);
if(dist<=(mid)){
if(!ok[j])cnt++;
ok[j]=true;
}
}
}
if(cnt==n){
ans=mid;
hi=mid-1;
}
else{
lo=mid+1;
}
}
pw.println(Math.sqrt(ans));
}
public static void main(String[] args) throws Exception{
sc=new MScanner(System.in);
// sc=new MScanner("troad.in");
pw = new PrintWriter(System.out);
int tc=1;
// tc=sc.nextInt();
for(curt=1;curt<=tc;curt++) {
// pw.printf("Case #%d: ", curt);
main();
}
pw.flush();
}
static int curt;
static PrintWriter pw;
static MScanner sc;
static class MScanner {
StringTokenizer st;
BufferedReader br;
public MScanner(InputStream system) {
br = new BufferedReader(new InputStreamReader(system));
}
public MScanner(String file) throws Exception {
br = new BufferedReader(new FileReader(file));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int[] intArr(int n) throws IOException {
int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
return in;
}
public long[] longArr(int n) throws IOException {
long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
return in;
}
public int[] intSortedArr(int n) throws IOException {
int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
shuffle(in);
Arrays.sort(in);
return in;
}
public long[] longSortedArr(int n) throws IOException {
long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
shuffle(in);
Arrays.sort(in);
return in;
}
public Integer[] IntegerArr(int n) throws IOException {
Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
return in;
}
public Long[] LongArr(int n) throws IOException {
Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
return in;
}
public String nextLine() throws IOException {
return br.readLine();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public char nextChar() throws IOException {
return next().charAt(0);
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public boolean ready() throws IOException {
return br.ready();
}
public void waitForInput() throws InterruptedException {
Thread.sleep(3000);
}
}
static void dbg(int[]in) {
System.out.println(Arrays.toString(in));
}
static void dbg(long[]in) {
System.out.println(Arrays.toString(in));
}
static void sort(int[]in) {
shuffle(in);
Arrays.sort(in);
}
static void sort(long[]in) {
shuffle(in);
Arrays.sort(in);
}
static void shuffle(int[]in) {
for(int i=0;i<in.length;i++) {
int idx=(int)(Math.random()*in.length);
int tmp=in[i];
in[i]=in[idx];
in[idx]=tmp;
}
}
static void shuffle(long[]in) {
for(int i=0;i<in.length;i++) {
int idx=(int)(Math.random()*in.length);
long tmp=in[i];
in[i]=in[idx];
in[idx]=tmp;
}
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | B - Light It Up |
| ユーザ | TheSawan |
| 言語 | Java (OpenJDK 1.8.0) |
| 得点 | 200 |
| コード長 | 4814 Byte |
| 結果 | AC |
| 実行時間 | 227 ms |
| メモリ | 27284 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 200 / 200 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| sample_01.txt | AC | 70 ms | 25448 KiB |
| sample_02.txt | AC | 71 ms | 25444 KiB |
| sample_03.txt | AC | 66 ms | 25444 KiB |
| test_01.txt | AC | 68 ms | 25388 KiB |
| test_02.txt | AC | 66 ms | 25160 KiB |
| test_03.txt | AC | 62 ms | 25208 KiB |
| test_04.txt | AC | 66 ms | 25216 KiB |
| test_05.txt | AC | 75 ms | 26324 KiB |
| test_06.txt | AC | 176 ms | 26868 KiB |
| test_07.txt | AC | 156 ms | 26888 KiB |
| test_08.txt | AC | 139 ms | 26816 KiB |
| test_09.txt | AC | 182 ms | 27172 KiB |
| test_10.txt | AC | 70 ms | 25832 KiB |
| test_11.txt | AC | 83 ms | 26504 KiB |
| test_12.txt | AC | 97 ms | 26944 KiB |
| test_13.txt | AC | 82 ms | 26500 KiB |
| test_14.txt | AC | 94 ms | 26580 KiB |
| test_15.txt | AC | 77 ms | 26280 KiB |
| test_16.txt | AC | 77 ms | 26000 KiB |
| test_17.txt | AC | 158 ms | 27192 KiB |
| test_18.txt | AC | 147 ms | 27284 KiB |
| test_19.txt | AC | 199 ms | 27176 KiB |
| test_20.txt | AC | 78 ms | 26464 KiB |
| test_21.txt | AC | 226 ms | 27132 KiB |
| test_22.txt | AC | 158 ms | 27136 KiB |
| test_23.txt | AC | 185 ms | 27136 KiB |
| test_24.txt | AC | 112 ms | 26776 KiB |
| test_25.txt | AC | 82 ms | 26460 KiB |
| test_26.txt | AC | 227 ms | 27168 KiB |
| test_27.txt | AC | 99 ms | 26852 KiB |