結果

問題 No.190 Dry Wet Moist
ユーザー itezpaceitezpace
提出日時 2016-11-09 07:48:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,195 bytes
コンパイル時間 3,936 ms
コンパイル使用メモリ 79,072 KB
実行使用メモリ 69,756 KB
最終ジャッジ日時 2024-11-25 05:25:19
合計ジャッジ時間 19,895 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 179 ms
55,928 KB
testcase_01 AC 169 ms
55,680 KB
testcase_02 AC 178 ms
55,856 KB
testcase_03 AC 185 ms
56,172 KB
testcase_04 AC 194 ms
55,808 KB
testcase_05 AC 194 ms
56,016 KB
testcase_06 AC 184 ms
55,988 KB
testcase_07 WA -
testcase_08 AC 244 ms
59,860 KB
testcase_09 AC 229 ms
59,812 KB
testcase_10 WA -
testcase_11 AC 251 ms
59,132 KB
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 AC 873 ms
65,680 KB
testcase_23 AC 832 ms
69,756 KB
testcase_24 AC 845 ms
68,092 KB
testcase_25 AC 174 ms
55,944 KB
testcase_26 AC 174 ms
55,844 KB
testcase_27 WA -
testcase_28 AC 606 ms
60,656 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

import java.util.Scanner;
public class Yuki190 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
Integer N = sc.nextInt();
int ary1[], ary2[];
ary1 = new int[100001];
ary2 = new int[100001];
Integer pn = 0, nn =0, zn=0;
for(int i = 0; i < 2*N; i++){
Integer A = sc.nextInt();
if(A > 0){
ary1[A] += 1;
pn += 1;
} else if(A < 0){
Integer A2 = A * -1;
ary2[A2] += 1;
nn += 1;
} else if(A == 0){
ary1[A] += 1;
zn += 1;
}
}
Integer D=0, W=0, M=0;
for(int i=0; i < 100001; ++i){
if(ary1[i] > 0 && ary2[i] > 0) {
int a = ary1[i];
int b = ary2[i];
int c;
if(a <= b){
c = a;
} else {
c = b;
}
M += c;
}
}
Integer Z = zn/2;
M += Z;
Integer cnt_d = 0, pos_d = 100001;
for(int i = 100000; i >= 0; i--){
if(ary2[i] > 0){
for(int j = i+1; j < pos_d; j++){
if(ary1[j] > 0) cnt_d += ary1[j];
}
pos_d = i+1;
int a = ary2[i];
int b = cnt_d;
int c;
if(a <= b){
c = a;
} else {
c = b;
}
D += c;
cnt_d -= c;
}
}
Integer dn1 = pn - D;
int a_d = dn1;
int b_d = zn;
int c_d;
if(a_d <= b_d){
c_d = a_d;
} else {
c_d = b_d;
}
W += c_d;
dn1 -= c_d;
Integer dn2 = dn1 / 2;
D += dn2;
Integer cnt_w = 0, pos_w = 100001;
for(int i = 100000; i >= 0; i--){
if(ary1[i] > 0){
for(int j = i+1; j < pos_w; j++){
if(ary2[j] > 0) cnt_w += ary2[j];
}
pos_w = i+1;
int a = ary1[i];
int b = cnt_w;
int c;
if(a <= b){
c = a;
} else {
c = b;
}
W += c;
cnt_w -= c;
}
}
Integer wn1 = nn - W;
int a_w = wn1;
int b_w = zn;
int c_w;
if(a_w <= b_w){
c_w = a_w;
} else {
c_w = b_w;
}
W += c_w;
wn1 -= c_w;
Integer wn2 = wn1 / 2;
W += wn2;
System.out.println(W + " " + D + " " + M);
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0