結果

問題 No.190 Dry Wet Moist
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-11-01 17:44:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,809 bytes
コンパイル時間 863 ms
コンパイル使用メモリ 67,292 KB
実行使用メモリ 5,056 KB
最終ジャッジ日時 2023-08-16 12:16:45
合計ジャッジ時間 2,625 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,444 KB
testcase_07 WA -
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,376 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 73 ms
5,056 KB
testcase_23 AC 77 ms
4,840 KB
testcase_24 AC 78 ms
4,892 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 24 ms
4,460 KB
testcase_29 AC 30 ms
4,540 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]);
		}
	}

	// printf("moist %d\n", moist);
	//wet
	int wet = 0;
	int l = 0, r = 0;

	while(r < a.size() && l < b.size()){
		while(a[r] - b[l] < 1)r++;
		wet++;
		l++;
		r++;
		if(l == b.size()) break;
	}
	wet += (a.size() - wet) / 2;

	// 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