結果

問題 No.190 Dry Wet Moist
ユーザー MayimgMayimg
提出日時 2020-07-27 12:15:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 1,070 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 210,048 KB
実行使用メモリ 14,932 KB
最終ジャッジ日時 2023-09-11 05:47:09
合計ジャッジ時間 5,646 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 44 ms
6,700 KB
testcase_13 AC 56 ms
7,080 KB
testcase_14 AC 42 ms
6,284 KB
testcase_15 AC 64 ms
7,852 KB
testcase_16 AC 83 ms
8,516 KB
testcase_17 AC 10 ms
4,784 KB
testcase_18 AC 35 ms
6,088 KB
testcase_19 AC 82 ms
8,400 KB
testcase_20 AC 53 ms
7,100 KB
testcase_21 AC 8 ms
4,452 KB
testcase_22 AC 144 ms
14,876 KB
testcase_23 AC 119 ms
10,220 KB
testcase_24 AC 155 ms
14,932 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 72 ms
8,056 KB
testcase_28 AC 29 ms
5,572 KB
testcase_29 AC 39 ms
6,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  auto calc = [] (vector<int> a, vector<int> b, int zero) -> int {
    int res = 0;
    multiset<int> st;
    for (auto& x : b) st.insert(x);
    for (int i = 0; i < zero; i++) a.push_back(0);
    sort(a.rbegin(), a.rend());
    for (auto& x : a) {
      auto it = st.upper_bound(x);
      if (it == st.end()) continue;
      st.erase(it);
      res++;
    }
    return res + (int) st.size() / 2;
  };
  int n;
  cin >> n;
  vector<int> po, ne;
  vector<int> cp(101010), cn(101010);
  int z = 0;
  for (int i = 0; i < n + n; i++) {
    int a;
    cin >> a;
    if (a > 0) {
      po.push_back(a);
      cp[a]++;
    }
    if (a < 0) {
      ne.push_back(-a);
      cn[-a]++;
    }
    if (a == 0) z++;
  }
  int dry = calc(po, ne, z);
  int wet = calc(ne, po, z);
  int moist = 0;
  for (int i = 0; i < 101010; i++) {
    moist += min(cp[i], cn[i]);
  }
  moist += z / 2;
  cout << dry << " " << wet << " " << moist << endl;
  return 0;
}
0