結果

問題 No.190 Dry Wet Moist
ユーザー __math__math
提出日時 2015-04-22 00:29:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,763 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 100,624 KB
実行使用メモリ 5,804 KB
最終ジャッジ日時 2023-09-18 04:00:47
合計ジャッジ時間 2,733 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 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 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 30 ms
4,432 KB
testcase_13 AC 37 ms
4,480 KB
testcase_14 AC 29 ms
4,688 KB
testcase_15 AC 40 ms
4,708 KB
testcase_16 AC 52 ms
5,020 KB
testcase_17 AC 8 ms
4,380 KB
testcase_18 AC 23 ms
4,380 KB
testcase_19 AC 51 ms
5,056 KB
testcase_20 AC 35 ms
4,520 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 60 ms
5,804 KB
testcase_23 AC 63 ms
5,056 KB
testcase_24 AC 59 ms
4,980 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 40 ms
4,552 KB
testcase_28 AC 18 ms
4,376 KB
testcase_29 AC 23 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <limits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

// #pragma comment(linker,"/STACK:36777216")

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> void chmax(T& l, const T r) { l = max(l, r); }
template<class T> void chmin(T& l, const T r) { l = min(l, r); }

int get_dry(vector<int> x){
	sort(x.begin(), x.end());
	int ans = 0;
	int r = sz(x) - 1;
	FOR(i, sz(x)){
		if (x[i] >= 0) break;
		while (r > i && x[i] + x[r] >= 0) r--;
		if (r <= i) break;
		ans++;
		r--;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(2 * n);
	FOR(i,2*n) scanf("%d", &a[i]);
	int dry = get_dry(a);
	FOR(i, 2 * n) a[i] *= -1;
	int wet = get_dry(a);

	static int t[ten(5) + 10] = {};
	int zeros = 0;
	vector<int> mus;
	for (auto x : a) {
		if (x < 0) mus.push_back(-x);
		else if (x == 0)zeros++;
		else t[x]++;
	}

	int moist = zeros / 2;
	for (auto x : mus) {
		if (t[x]) {
			moist++;
			t[x]--;
		}
	}

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


	return 0;
}
0