結果

問題 No.190 Dry Wet Moist
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-11-01 18:00:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,971 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 66,572 KB
実行使用メモリ 4,868 KB
最終ジャッジ日時 2023-08-16 12:18:07
合計ジャッジ時間 2,792 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,504 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 36 ms
4,560 KB
testcase_13 AC 46 ms
4,868 KB
testcase_14 AC 35 ms
4,408 KB
testcase_15 AC 48 ms
4,604 KB
testcase_16 AC 62 ms
4,696 KB
testcase_17 AC 10 ms
4,384 KB
testcase_18 AC 29 ms
4,484 KB
testcase_19 AC 60 ms
4,836 KB
testcase_20 AC 43 ms
4,480 KB
testcase_21 AC 7 ms
4,484 KB
testcase_22 AC 71 ms
4,796 KB
testcase_23 AC 76 ms
4,796 KB
testcase_24 AC 76 ms
4,788 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 49 ms
4,476 KB
testcase_28 AC 23 ms
4,572 KB
testcase_29 AC 29 ms
4,432 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