結果

問題 No.190 Dry Wet Moist
ユーザー cielciel
提出日時 2015-04-22 04:25:27
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 724 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 47,540 KB
実行使用メモリ 11,348 KB
最終ジャッジ日時 2023-09-18 08:02:57
合計ジャッジ時間 6,904 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int dry(vector<int> &v){
	int R=0,lo=0,hi=v.size()-1;
	for(;lo<hi;){
		for(;lo<hi;hi--)if(v[lo]+v[hi]<0)break;
		if(lo==hi)break;
	}
	return R;
}

int wet(vector<int> &v){
	int R=0,lo=0,hi=v.size()-1;
	for(;lo<hi;){
		for(;lo<hi;lo++)if(v[lo]+v[hi]>0)break;
		if(lo==hi)break;
	}
	return R;
}

int moist(vector<int> &v){
	int R=0,lo=0,hi=v.size()-1;
	for(;lo<hi;v[lo]+v[hi]==0?R++,hi--:1,lo++){
		for(;lo<hi;hi--)if(v[lo]+v[hi]<=0)break;
		if(lo==hi)break;
	}
	return R;
}

int main(){
	int N;
	scanf("%d",&N);
	vector<int>v(N*=2);
	for(int i=0;i<N;i++)scanf("%d",&v[i]);
	sort(v.begin(),v.end());
	printf("%d %d %d\n",dry(v),wet(v),moist(v));
}
0