結果

問題 No.190 Dry Wet Moist
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-11-01 18:07:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,715 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 66,004 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-03 20:43:37
合計ジャッジ時間 2,535 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 40 ms
6,944 KB
testcase_13 AC 49 ms
6,944 KB
testcase_14 AC 39 ms
6,940 KB
testcase_15 AC 52 ms
6,940 KB
testcase_16 AC 66 ms
6,940 KB
testcase_17 AC 10 ms
6,940 KB
testcase_18 AC 31 ms
6,940 KB
testcase_19 AC 65 ms
6,944 KB
testcase_20 AC 45 ms
6,940 KB
testcase_21 AC 7 ms
6,940 KB
testcase_22 AC 75 ms
6,940 KB
testcase_23 AC 82 ms
6,944 KB
testcase_24 AC 80 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 53 ms
6,940 KB
testcase_28 AC 25 ms
6,944 KB
testcase_29 AC 31 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int memo1[100010], memo2[100010];
int main(void){
	int n; cin >> n;
	rep(i, 100010) memo1[i] = memo2[i] = 0;
	vector<int> a, b;
	rep(i, 2 * n){
		int t; cin >> t;
		if(t >= 0){
			// printf("t %d\n", t);
			a.pb(t);
			memo1[t]++;
		}else{
			// printf("t %d\n", t);
			t *= -1;
			b.pb(t);
			memo2[t]++;
		}
	}

	sort(all(a)); sort(all(b));

	int moist = 0;
	rep(i, 100010){
		if(memo1[i]> 0 && memo2[i] > 0){
			moist += min(memo1[i], memo2[i]);
		}
	}
	moist += memo1[0] / 2;

	int wet = 0;
	int l = 0, r = 0;
	int usedzero = 0;
	while(r < a.size() && l < b.size()){
		while(a[r] - b[l] < 1)r++;
		if(l >= b.size()) break;
		if(r >= a.size()) break;
		wet++;
		if(a[r] == 0) usedzero++;
		l++;
		r++;
	}
	int notzero = a.size() - wet - memo1[0];
	if(notzero >= memo1[0]) wet += (notzero + memo1[0]) / 2;
	else wet += notzero;

	int dry = 0;
	l = 0, r = 0;
	while(r < b.size() && l < a.size()){
		while(b[r] - a[l] < 1)r++;
		if(l >= a.size()) break;
		if(r >= b.size()) break;
		dry++;
		l++;
		r++;
	}
	dry += (b.size() - dry) / 2;
	
	printf("%d %d %d\n", dry, wet, moist);
	return 0;
}
0