結果

問題 No.190 Dry Wet Moist
ユーザー itezpaceitezpace
提出日時 2016-11-09 07:48:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,195 bytes
コンパイル時間 4,171 ms
コンパイル使用メモリ 78,548 KB
実行使用メモリ 66,084 KB
最終ジャッジ日時 2023-08-16 15:35:16
合計ジャッジ時間 19,764 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
42,512 KB
testcase_01 AC 179 ms
42,812 KB
testcase_02 AC 177 ms
42,624 KB
testcase_03 AC 184 ms
43,008 KB
testcase_04 AC 185 ms
42,788 KB
testcase_05 AC 182 ms
42,656 KB
testcase_06 AC 181 ms
42,748 KB
testcase_07 WA -
testcase_08 AC 245 ms
45,728 KB
testcase_09 AC 236 ms
44,572 KB
testcase_10 WA -
testcase_11 AC 235 ms
45,156 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 755 ms
50,896 KB
testcase_23 AC 796 ms
51,284 KB
testcase_24 AC 777 ms
50,596 KB
testcase_25 AC 164 ms
42,780 KB
testcase_26 AC 159 ms
42,640 KB
testcase_27 WA -
testcase_28 AC 513 ms
47,840 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);
  }
}
0