結果

問題 No.190 Dry Wet Moist
ユーザー beetbeet
提出日時 2019-03-02 23:19:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 694 ms / 2,000 ms
コード長 978 bytes
コンパイル時間 2,416 ms
コンパイル使用メモリ 212,536 KB
実行使用メモリ 13,156 KB
最終ジャッジ日時 2023-09-05 17:35:39
合計ジャッジ時間 9,339 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 214 ms
8,664 KB
testcase_13 AC 292 ms
10,168 KB
testcase_14 AC 212 ms
8,664 KB
testcase_15 AC 325 ms
10,720 KB
testcase_16 AC 463 ms
12,836 KB
testcase_17 AC 35 ms
5,020 KB
testcase_18 AC 159 ms
7,560 KB
testcase_19 AC 440 ms
12,808 KB
testcase_20 AC 280 ms
9,724 KB
testcase_21 AC 22 ms
4,376 KB
testcase_22 AC 592 ms
13,156 KB
testcase_23 AC 694 ms
13,096 KB
testcase_24 AC 613 ms
13,028 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 362 ms
10,284 KB
testcase_28 AC 127 ms
7,388 KB
testcase_29 AC 171 ms
8,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0