結果
問題 | No.190 Dry Wet Moist |
ユーザー |
![]() |
提出日時 | 2019-03-02 23:19:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 468 ms / 2,000 ms |
コード長 | 978 bytes |
コンパイル時間 | 2,019 ms |
コンパイル使用メモリ | 206,932 KB |
最終ジャッジ日時 | 2025-01-06 21:52:54 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE signed main(){ int n; cin>>n; n*=2; vector<int> a(n); for(int i=0;i<n;i++) cin>>a[i]; for(int uku=0;uku<2;uku++){ for(int &x:a) x*=-1; multiset<int> ms; for(int x:a) ms.emplace(x); int res=0; while(ms.size()>1u){ int x=*ms.begin();ms.erase(ms.begin()); auto it=ms.upper_bound(-x); if(it==ms.end()) continue; res++; ms.erase(it); } cout<<res<<" "; } //Moist { int res=0; map<int, int> cnt; for(int x:a) cnt[x]++; for(int x:a){ if(cnt[x]==0) continue; if(x==0){ res+=cnt[x]/2; }else{ res+=min(cnt[x],cnt[-x]); } cnt[x]=0; cnt[-x]=0; } cout<<res<<endl; } return 0; }