結果
| 問題 |
No.190 Dry Wet Moist
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-09-04 16:21:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 287 ms / 2,000 ms |
| コード長 | 1,177 bytes |
| コンパイル時間 | 599 ms |
| コンパイル使用メモリ | 62,700 KB |
| 実行使用メモリ | 31,488 KB |
| 最終ジャッジ日時 | 2024-11-15 20:12:28 |
| 合計ジャッジ時間 | 4,027 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 |
ソースコード
#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(xs.begin());
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(xs.find(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;
}
はむ吉🐹