結果

問題 No.190 Dry Wet Moist
ユーザー CleyLCleyL
提出日時 2023-06-19 16:42:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 948 ms
コンパイル使用メモリ 94,172 KB
実行使用メモリ 13,024 KB
最終ジャッジ日時 2023-09-09 12:04:08
合計ジャッジ時間 3,995 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 75 ms
7,256 KB
testcase_13 AC 95 ms
7,992 KB
testcase_14 AC 66 ms
7,332 KB
testcase_15 AC 100 ms
8,604 KB
testcase_16 AC 137 ms
9,456 KB
testcase_17 AC 15 ms
4,560 KB
testcase_18 AC 60 ms
6,724 KB
testcase_19 AC 139 ms
9,308 KB
testcase_20 AC 88 ms
7,880 KB
testcase_21 AC 10 ms
4,380 KB
testcase_22 AC 169 ms
12,108 KB
testcase_23 AC 251 ms
13,024 KB
testcase_24 AC 166 ms
7,784 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 120 ms
9,080 KB
testcase_28 AC 50 ms
6,696 KB
testcase_29 AC 63 ms
7,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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