結果
問題 |
No.190 Dry Wet Moist
|
ユーザー |
![]() |
提出日時 | 2016-09-04 16:18:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,159 bytes |
コンパイル時間 | 708 ms |
コンパイル使用メモリ | 64,344 KB |
実行使用メモリ | 31,488 KB |
最終ジャッジ日時 | 2024-11-15 20:12:23 |
合計ジャッジ時間 | 5,782 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 2 WA * 26 |
ソースコード
#include <ciso646> #include <cstdlib> #include <iostream> #include <set> typedef int Moisture; typedef std::multiset<Moisture> Reactants; int moist(Reactants xs) { int ans = 0; while (not xs.empty()) { auto x = *xs.begin(); xs.erase(x); auto itr = xs.find(-x); if (itr != xs.end()) { ans++; xs.erase(itr); } } return ans; } int wet(Reactants xs) { int ans = 0; while (not xs.empty()) { auto x = *xs.rbegin(); xs.erase(x); auto itr = xs.lower_bound(1 - x); if (itr != xs.end()) { ans++; xs.erase(itr); } } return ans; } int dry(const Reactants& xs) { Reactants ys; for (auto x : xs) { ys.insert(-x); } return wet(ys); } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int n; std::cin >> n; Reactants xs; for (auto i = 0; i < 2 * n; i++) { Moisture x; std::cin >> x; xs.insert(x); } std::cout << dry(xs) << ' ' << wet(xs) << ' ' << moist(xs) << std::endl; }