結果

問題 No.947 ABC包囲網
ユーザー 37zigen37zigen
提出日時 2020-04-04 18:35:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 433 ms / 2,000 ms
コード長 1,309 bytes
コンパイル時間 3,847 ms
コンパイル使用メモリ 75,876 KB
実行使用メモリ 62,472 KB
最終ジャッジ日時 2023-09-16 06:05:31
合計ジャッジ時間 21,848 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
57,228 KB
testcase_01 AC 129 ms
57,652 KB
testcase_02 AC 138 ms
57,216 KB
testcase_03 AC 132 ms
57,532 KB
testcase_04 AC 126 ms
57,376 KB
testcase_05 AC 127 ms
57,456 KB
testcase_06 AC 127 ms
57,528 KB
testcase_07 AC 126 ms
57,568 KB
testcase_08 AC 127 ms
57,528 KB
testcase_09 AC 127 ms
57,468 KB
testcase_10 AC 123 ms
57,220 KB
testcase_11 AC 129 ms
57,228 KB
testcase_12 AC 132 ms
57,192 KB
testcase_13 AC 129 ms
57,436 KB
testcase_14 AC 127 ms
57,696 KB
testcase_15 AC 188 ms
57,960 KB
testcase_16 AC 169 ms
57,700 KB
testcase_17 AC 172 ms
57,696 KB
testcase_18 AC 208 ms
58,228 KB
testcase_19 AC 208 ms
58,308 KB
testcase_20 AC 208 ms
58,348 KB
testcase_21 AC 207 ms
56,808 KB
testcase_22 AC 206 ms
58,476 KB
testcase_23 AC 201 ms
58,432 KB
testcase_24 AC 202 ms
58,876 KB
testcase_25 AC 201 ms
58,440 KB
testcase_26 AC 194 ms
58,444 KB
testcase_27 AC 201 ms
58,744 KB
testcase_28 AC 431 ms
61,796 KB
testcase_29 AC 370 ms
62,324 KB
testcase_30 AC 411 ms
62,380 KB
testcase_31 AC 407 ms
61,976 KB
testcase_32 AC 403 ms
60,488 KB
testcase_33 AC 405 ms
62,264 KB
testcase_34 AC 407 ms
62,224 KB
testcase_35 AC 433 ms
62,108 KB
testcase_36 AC 432 ms
62,452 KB
testcase_37 AC 424 ms
60,380 KB
testcase_38 AC 408 ms
61,920 KB
testcase_39 AC 397 ms
62,236 KB
testcase_40 AC 378 ms
62,084 KB
testcase_41 AC 370 ms
62,472 KB
testcase_42 AC 398 ms
61,860 KB
testcase_43 AC 406 ms
61,916 KB
testcase_44 AC 376 ms
61,992 KB
testcase_45 AC 383 ms
62,024 KB
testcase_46 AC 394 ms
62,032 KB
testcase_47 AC 394 ms
61,688 KB
testcase_48 AC 375 ms
61,676 KB
testcase_49 AC 424 ms
61,840 KB
testcase_50 AC 406 ms
62,128 KB
testcase_51 AC 151 ms
57,224 KB
testcase_52 AC 149 ms
57,216 KB
testcase_53 AC 146 ms
57,224 KB
testcase_54 AC 130 ms
55,704 KB
testcase_55 AC 130 ms
55,728 KB
testcase_56 AC 128 ms
57,460 KB
testcase_57 AC 216 ms
58,192 KB
testcase_58 AC 214 ms
58,336 KB
testcase_59 AC 214 ms
58,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main implements Runnable{

	public static void main(String[] args) {
		new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
	}
	
	public void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long[][] P=new long[N][2];
		for(int i=0;i<N;++i) {
			P[i][0]=sc.nextLong();
			P[i][1]=sc.nextLong();
		}
		Arrays.sort(P, new Comparator<long[]>() {
			@Override
			public int compare(long[] o1, long[] o2) {
				double ang1=Math.atan2(o1[1], o1[0]);
				double ang2=Math.atan2(o2[1], o2[0]);
				if(ang1<0)ang1+=Math.PI*2;
				if(ang2<0)ang2+=Math.PI*2;
				if(Math.abs(ang1-ang2)>Math.PI/4)return Double.compare(ang1, ang2);
				return Long.signum(-(o1[0]*o2[1]-o1[1]*o2[0]));
			}
		});
		long ans=0;
		for(int i=0;i+1<N;++i) {
			if(P[i][1]<0||(P[i][1]==0&&P[i][0]<0))break;
			int first=i+1;
			while(first<N&&P[i][0]*P[first][1]-P[i][1]*P[first][0]>=0)++first;
			int last=first;
			for(int j=i+1;j<first;++j) {
				if(P[i][0]*P[j][1]-P[i][1]*P[j][0]<=0)continue;
				while(last<N&&P[j][0]*P[last][1]-P[j][1]*P[last][0]>0)++last;
				ans+=last-first;
			}
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

0