結果

問題 No.190 Dry Wet Moist
ユーザー y_mazuny_mazun
提出日時 2015-04-22 20:50:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,389 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 73,604 KB
実行使用メモリ 8,152 KB
最終ジャッジ日時 2023-09-18 08:21:48
合計ジャッジ時間 2,480 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 72 ms
7,368 KB
testcase_23 AC 86 ms
8,152 KB
testcase_24 AC 72 ms
7,368 KB
testcase_25 WA -
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 22 ms
5,260 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <map>
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int solvePlus(vector<int> &p, vector<int> &m, vector<int> &z){
  int cnt = 0;

  int pp = 0;
  int mp = 0;

  while(pp < (int)p.size() && mp < (int)m.size()){
    while(pp < (int)p.size() && p[pp] <= m[mp]) pp++;
    if(pp != (int)p.size()) cnt++;
    mp++; pp++;
  }

  int rest = p.size() - cnt;
  int zc = min(rest, (int)z.size());
  rest -= zc;

  return cnt + zc + rest / 2;
}

int solveMinus(vector<int> &p, vector<int> &m, vector<int> &z){
  return solvePlus(m, p, z);
}

int solveZero(vector<int> &p, vector<int> &m, vector<int> &z){
  map<int, int> mc;
  REP(i,m.size()) mc[m[i]]++;

  int ret = z.size();
  REP(i,p.size()){
    if(mc[p[i]] > 0){
      ret++;
      mc[p[i]]--;
    }
  }

  return ret;
}

int main(){
  const int n = getInt();
  vector<int> p;
  vector<int> m;
  vector<int> z;

  REP(i,2*n){
    const int a = getInt();
    if(a == 0) z.push_back(a);
    else if(a > 0) p.push_back(a);
    else m.push_back(-a);
  }

  sort(p.begin(), p.end());
  sort(m.begin(), m.end());

  const int dry = solveMinus(p, m, z);
  const int wet = solvePlus(p, m, z);
  const int moist = solveZero(p, m, z);

  printf("%d %d %d\n", dry, wet, moist);

  return 0;
}
0