結果

問題 No.190 Dry Wet Moist
ユーザー not_522not_522
提出日時 2015-08-19 22:21:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 153,364 KB
実行使用メモリ 6,500 KB
最終ジャッジ日時 2023-09-25 13:28:27
合計ジャッジ時間 4,353 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 37 ms
5,020 KB
testcase_13 AC 46 ms
5,344 KB
testcase_14 AC 36 ms
5,108 KB
testcase_15 AC 51 ms
5,532 KB
testcase_16 AC 65 ms
6,200 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 30 ms
4,636 KB
testcase_19 AC 63 ms
6,500 KB
testcase_20 AC 44 ms
5,268 KB
testcase_21 AC 6 ms
4,380 KB
testcase_22 AC 75 ms
6,368 KB
testcase_23 AC 80 ms
6,384 KB
testcase_24 AC 80 ms
6,172 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 51 ms
5,184 KB
testcase_28 AC 23 ms
4,376 KB
testcase_29 AC 29 ms
4,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(2 * n);
  for (int& i : a) cin >> i;
  sort(a.begin(), a.end());
  deque<int> b(a.begin(), a.end()), c = b, d = b;
  int dry = 0, wet = 0, moist = 0;
  while (b.size() > 1u) {
    if (b.front() + b.back() < 0) {
      ++dry;
      b.pop_front();
    }
    b.pop_back();
  }
  while (c.size() > 1u) {
    if (c.front() + c.back() > 0) {
      ++wet;
      c.pop_back();
    }
    c.pop_front();
  }
  while (d.size() > 1u) {
    if (d.front() + d.back() == 0) {
      ++moist;
      d.pop_front();
      d.pop_back();
    } else if (d.front() + d.back() < 0) {
      d.pop_front();
    } else {
      d.pop_back();
    }
  }
  cout << dry << " " << wet << " " << moist << endl;
}
0