結果

問題 No.190 Dry Wet Moist
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-12 23:33:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 859 ms / 2,000 ms
コード長 1,155 bytes
コンパイル時間 3,094 ms
コンパイル使用メモリ 79,528 KB
実行使用メモリ 71,732 KB
最終ジャッジ日時 2023-10-17 22:37:03
合計ジャッジ時間 18,522 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
58,640 KB
testcase_01 AC 165 ms
58,556 KB
testcase_02 AC 169 ms
58,592 KB
testcase_03 AC 170 ms
58,632 KB
testcase_04 AC 173 ms
56,600 KB
testcase_05 AC 171 ms
58,480 KB
testcase_06 AC 165 ms
58,516 KB
testcase_07 AC 235 ms
61,228 KB
testcase_08 AC 227 ms
62,252 KB
testcase_09 AC 220 ms
59,260 KB
testcase_10 AC 220 ms
58,232 KB
testcase_11 AC 221 ms
58,564 KB
testcase_12 AC 640 ms
66,640 KB
testcase_13 AC 683 ms
68,280 KB
testcase_14 AC 622 ms
63,428 KB
testcase_15 AC 703 ms
67,740 KB
testcase_16 AC 806 ms
71,548 KB
testcase_17 AC 393 ms
62,660 KB
testcase_18 AC 577 ms
63,004 KB
testcase_19 AC 771 ms
71,568 KB
testcase_20 AC 673 ms
68,104 KB
testcase_21 AC 359 ms
62,344 KB
testcase_22 AC 808 ms
70,932 KB
testcase_23 AC 853 ms
71,732 KB
testcase_24 AC 859 ms
70,956 KB
testcase_25 AC 167 ms
58,524 KB
testcase_26 AC 172 ms
58,552 KB
testcase_27 AC 680 ms
67,800 KB
testcase_28 AC 532 ms
62,756 KB
testcase_29 AC 580 ms
62,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    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 dry = 0;
    int wet = 0;
    int moist = 0;
    int left = 0;
    int right = 2 * n - 1;
    for(int i = 0; i < 2 * n; i++) {
      while(i < right) {
        if(a[i] + a[right] < 0) {
          dry++;
          right--;
          break;
        } else {
          right--;
        }
      }
    }
    right = 2 * n - 1;
    for(int i = 2 * n - 1; i >= 0; i--) {
      while(left < i) {
        if(a[i] + a[left] > 0) {
          wet++;
          left++;
          break;
        } else {
          left++;
        }
      }
    }
    left = 0;
    for(int i = 0; i < 2 * n; i++) {
      while(i < right) {
        if(a[i] + a[right] == 0) {
          moist++;
          right--;
          break;
        } else if(a[i] + a[right] > 0) {
          right--;
        } else {
          break;
        }
      }
    }
    System.out.println(dry + " " + wet + " " + moist);
  }
}
0