結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 37 ms
6,940 KB
testcase_13 AC 44 ms
6,940 KB
testcase_14 AC 34 ms
6,940 KB
testcase_15 AC 47 ms
6,940 KB
testcase_16 AC 61 ms
6,944 KB
testcase_17 AC 9 ms
6,944 KB
testcase_18 AC 28 ms
6,940 KB
testcase_19 AC 57 ms
6,940 KB
testcase_20 AC 40 ms
6,940 KB
testcase_21 AC 6 ms
6,940 KB
testcase_22 AC 68 ms
6,944 KB
testcase_23 AC 71 ms
6,940 KB
testcase_24 AC 72 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 WA -
testcase_27 AC 46 ms
6,944 KB
testcase_28 AC 21 ms
6,940 KB
testcase_29 AC 28 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));
	/*
	rep(i, a.size()){
		printf("%d ", a[i]);
	}
	printf("\n");
	rep(i, b.size()){
		printf("%d ", b[i]);
	}
	printf("\n");
	*/
	//moist
	int moist = 0;
	rep(i, 100010){
		// printf("%d %d\n", memo1[i], memo2[i]);
		if(memo1[i]> 0 && memo2[i] > 0){
			moist += min(memo1[i], memo2[i]);
		}
	}
	moist += memo1[0] / 2;

	// printf("moist %d\n", moist);
	//wet
	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++;
		wet++;
		if(a[r] == 0) usedzero++;
		l++;
		r++;
		if(l == b.size()) break;
	}
	int notzero = a.size() - wet - memo1[0];
	if(notzero >= memo1[0]) wet += (notzero + memo1[0]) / 2;
	else wet += notzero;

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