結果

問題 No.190 Dry Wet Moist
ユーザー tkzw_21tkzw_21
提出日時 2015-07-16 15:05:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 148,688 KB
実行使用メモリ 4,744 KB
最終ジャッジ日時 2023-09-22 16:43:58
合計ジャッジ時間 3,465 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 35 ms
4,384 KB
testcase_13 AC 45 ms
4,380 KB
testcase_14 AC 35 ms
4,384 KB
testcase_15 AC 49 ms
4,384 KB
testcase_16 AC 62 ms
4,628 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 29 ms
4,380 KB
testcase_19 AC 60 ms
4,744 KB
testcase_20 AC 42 ms
4,380 KB
testcase_21 AC 7 ms
4,384 KB
testcase_22 AC 72 ms
4,572 KB
testcase_23 AC 76 ms
4,576 KB
testcase_24 AC 77 ms
4,572 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 3 ms
4,384 KB
testcase_27 AC 49 ms
4,404 KB
testcase_28 AC 23 ms
4,388 KB
testcase_29 AC 28 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(void){
	int n;
	cin >> n;
	n *= 2;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());

	int l = 0,r = a.size()-1;
	int wet = 0;
	while(l < r){
		if(a[r] + a[l] > 0){
			wet++;
			r--;
			l++;
		}else{
			l++;
		}
	}

	l = 0,r = a.size()-1;
	int dry = 0;
	while(l < r){
		if(a[r] + a[l] < 0){
			dry++;
			r--;
			l++;
		}else{
			r--;
		}
	}

	int moi = 0;
	vector<int> ar(200010);
	for(int i=0;i<n;i++){
		if(ar[-a[i]+100000] > 0){
			moi++;
			ar[-a[i]+100000]--;
		}
		else
			ar[a[i]+100000]++;
	}
	cout << dry << " " << wet << " " << moi << endl;

	return 0;
}
0