結果

問題 No.190 Dry Wet Moist
ユーザー 37zigen37zigen
提出日時 2020-03-27 06:30:04
言語 Java19
(openjdk 21)
結果
AC  
実行時間 912 ms / 2,000 ms
コード長 955 bytes
コンパイル時間 3,063 ms
コンパイル使用メモリ 76,640 KB
実行使用メモリ 67,204 KB
最終ジャッジ日時 2023-08-30 16:07:00
合計ジャッジ時間 21,608 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
57,200 KB
testcase_01 AC 169 ms
57,008 KB
testcase_02 AC 169 ms
57,024 KB
testcase_03 AC 177 ms
57,044 KB
testcase_04 AC 180 ms
56,772 KB
testcase_05 AC 181 ms
56,764 KB
testcase_06 AC 176 ms
56,960 KB
testcase_07 AC 248 ms
60,528 KB
testcase_08 AC 220 ms
59,468 KB
testcase_09 AC 232 ms
58,432 KB
testcase_10 AC 229 ms
58,740 KB
testcase_11 AC 239 ms
58,824 KB
testcase_12 AC 642 ms
62,408 KB
testcase_13 AC 721 ms
67,204 KB
testcase_14 AC 655 ms
61,764 KB
testcase_15 AC 721 ms
64,924 KB
testcase_16 AC 826 ms
64,720 KB
testcase_17 AC 401 ms
60,536 KB
testcase_18 AC 633 ms
61,192 KB
testcase_19 AC 824 ms
65,004 KB
testcase_20 AC 710 ms
65,424 KB
testcase_21 AC 366 ms
60,812 KB
testcase_22 AC 872 ms
65,512 KB
testcase_23 AC 912 ms
65,492 KB
testcase_24 AC 865 ms
65,348 KB
testcase_25 AC 167 ms
57,240 KB
testcase_26 AC 169 ms
56,996 KB
testcase_27 AC 714 ms
65,020 KB
testcase_28 AC 519 ms
61,960 KB
testcase_29 AC 581 ms
61,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main{
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
	
	int positive(int[] A) {
		int s=0,t=A.length-1;
		int ans=0;
		while(s<t) {
			while(s<t&&A[s]+A[t]<=0)++s;
			if(s==t)break;
			++ans;
			++s;--t;
		}
		return ans;
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] A=new int[2*N];
		for(int i=0;i<2*N;++i)A[i]=sc.nextInt();
		Arrays.sort(A);
		int zero=0,positive=0,negative=0;
		int s=0,t=A.length-1;
		while(s<t) {
			if(-A[s]==A[t]) {
				++s;--t;
				++zero;
			}else if(-A[s]>A[t])++s;
			else --t;
		}
		positive=positive(A);
		for(int i=0;i<A.length;++i)A[i]*=-1;
		Arrays.sort(A);
		negative=positive(A);
		System.out.println(negative+" "+positive+" "+zero);
	}

	public static void main(String[] args){
		new Main().run();
	}
	
}
0