結果
問題 | No.190 Dry Wet Moist |
ユーザー |
👑 |
提出日時 | 2023-06-19 16:42:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 255 ms / 2,000 ms |
コード長 | 751 bytes |
コンパイル時間 | 958 ms |
コンパイル使用メモリ | 89,520 KB |
最終ジャッジ日時 | 2025-02-14 22:57:54 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <map>using namespace std;int main(){int n;cin>>n;n*=2;vector<int> A(n);map<int,int> B;for(int i = 0; n > i; i++){cin>>A[i];B[A[i]]++;}sort(A.begin(), A.end());int nw = n-1;int dry = 0;for(int i = 0; i < nw ; i++){while(i < nw && A[i]+A[nw] >= 0)nw--;if(i < nw)dry++;nw--;}nw = 0;int wet = 0;for(int i = n-1; nw < i; i--){while(nw < i && A[nw]+A[i] <= 0)nw++;if(nw < i)wet++;nw++;}int moist = 0;for(auto x: B){if(x.first < 0)continue;else if(x.first == 0)moist += x.second/2;else moist += min(x.second, B[-x.first]);}cout << dry << " " << wet << " " << moist << endl;}