結果

問題 No.190 Dry Wet Moist
ユーザー 37zigen37zigen
提出日時 2020-03-27 06:44:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 873 ms / 2,000 ms
コード長 950 bytes
コンパイル時間 4,401 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 65,904 KB
最終ジャッジ日時 2023-08-30 16:08:25
合計ジャッジ時間 18,708 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
56,660 KB
testcase_01 AC 168 ms
56,668 KB
testcase_02 AC 170 ms
56,944 KB
testcase_03 AC 176 ms
57,208 KB
testcase_04 AC 177 ms
56,924 KB
testcase_05 AC 177 ms
56,784 KB
testcase_06 AC 174 ms
57,044 KB
testcase_07 AC 248 ms
60,000 KB
testcase_08 AC 228 ms
60,808 KB
testcase_09 AC 231 ms
59,112 KB
testcase_10 AC 221 ms
58,612 KB
testcase_11 AC 223 ms
59,340 KB
testcase_12 AC 648 ms
61,744 KB
testcase_13 AC 728 ms
65,904 KB
testcase_14 AC 663 ms
61,552 KB
testcase_15 AC 717 ms
65,532 KB
testcase_16 AC 790 ms
64,908 KB
testcase_17 AC 394 ms
60,808 KB
testcase_18 AC 589 ms
61,876 KB
testcase_19 AC 787 ms
63,644 KB
testcase_20 AC 670 ms
65,324 KB
testcase_21 AC 357 ms
60,864 KB
testcase_22 AC 873 ms
65,868 KB
testcase_23 AC 862 ms
65,396 KB
testcase_24 AC 854 ms
65,252 KB
testcase_25 AC 165 ms
56,772 KB
testcase_26 AC 167 ms
56,992 KB
testcase_27 AC 719 ms
65,056 KB
testcase_28 AC 529 ms
61,804 KB
testcase_29 AC 597 ms
61,420 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);
		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