結果

問題 No.190 Dry Wet Moist
ユーザー btkbtk
提出日時 2015-04-22 02:30:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,160 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-18 07:43:31
合計ジャッジ時間 7,262 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 WA -
testcase_17 AC 9 ms
4,376 KB
testcase_18 AC 28 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 6 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 RE -
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 RE -
testcase_28 AC 21 ms
4,376 KB
testcase_29 AC 27 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;

int N;
int A[100000];

int main(void){
	cin >> N;
	N <<= 1;
	for (int i = 0; i < N; i++)
		cin >> A[i];
	sort(A, A + N);
	int left = 0,right=N-1;
	int cnt;

	//Dry
	cnt = 0; left = 0; right = N - 1;
	while (left<right){
		while (left < right&&A[left] + A[right] >= 0)right--;
		if (left == right)break;
		else{
			cnt++;
			left++;
			right--;
		}
	}
	cout << cnt << " ";

	//Wet
	cnt = 0; left = 0; right = N - 1;
	while (left<right){
		while (left < right&&A[left] + A[right] <= 0)left++;
		if (left == right)break;
		else{
			cnt++;
			left++;
			right--;
		}
	}
	cout << cnt << " ";

	//Moist
	cnt = 0; left = 0; right = N - 1;
	while (left < right&&A[left] <= 0 && A[right] >= 0){
		if (-A[left] > A[right])
			left++;
		else
			if (-A[left] < A[right])
				right--;
			else
				cnt++, left++, right--;

	}
	cout << cnt << endl;

	return(0);
}
0