結果
問題 |
No.190 Dry Wet Moist
|
ユーザー |
|
提出日時 | 2020-05-22 03:26:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 141 ms / 2,000 ms |
コード長 | 944 bytes |
コンパイル時間 | 1,875 ms |
コンパイル使用メモリ | 177,208 KB |
実行使用メモリ | 13,440 KB |
最終ジャッジ日時 | 2024-10-03 04:53:43 |
合計ジャッジ時間 | 5,104 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr char newl = '\n'; int calc(const vector<int>& v, bool is_moist) { multiset<int> s(v.begin(), v.end()); int res = 0; while (!s.empty()) { auto it = s.begin(); int x = *it; s.erase(it); it = (is_moist ? s.find(-x) : s.upper_bound(-x)); if (it == s.end()) continue; ++res; s.erase(it); } return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; n <<= 1; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); int wet = calc(a, false); int moist = calc(a, true); for (int i = 0; i < n; i++) { a[i] = -a[i]; } reverse(a.begin(), a.end()); int dry = calc(a, false); cout << dry << " " << wet << " " << moist << newl; return 0; }