結果

問題 No.190 Dry Wet Moist
ユーザー 37zigen37zigen
提出日時 2020-03-27 06:43:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 989 bytes
コンパイル時間 2,910 ms
コンパイル使用メモリ 79,204 KB
実行使用メモリ 67,208 KB
最終ジャッジ日時 2023-08-30 16:08:03
合計ジャッジ時間 18,811 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 176 ms
57,436 KB
testcase_01 WA -
testcase_02 AC 178 ms
57,116 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 904 ms
65,544 KB
testcase_24 WA -
testcase_25 AC 172 ms
56,652 KB
testcase_26 AC 176 ms
56,916 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
		A=Arrays.stream(A).map(i->-i).sorted().toArray();
		negative=positive(A);
		System.out.println(negative+" "+positive+" "+zero);
	}

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