結果
問題 |
No.947 ABC包囲網
|
ユーザー |
|
提出日時 | 2020-04-04 18:19:38 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,285 bytes |
コンパイル時間 | 2,227 ms |
コンパイル使用メモリ | 86,892 KB |
実行使用メモリ | 48,968 KB |
最終ジャッジ日時 | 2024-07-03 07:37:21 |
合計ジャッジ時間 | 18,052 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 47 WA * 13 |
ソースコード
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)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));} }