結果

問題 No.190 Dry Wet Moist
ユーザー TatamoTatamo
提出日時 2016-11-01 17:18:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 1,458 bytes
コンパイル時間 3,568 ms
コンパイル使用メモリ 66,060 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-16 12:15:50
合計ジャッジ時間 4,724 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>

using namespace std;
#define cerr cerr << "[DBG] "
#define DBG(x) cerr << #x << ": " << x << endl
// http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.html
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { for (int i = 0; i < (int)v.size(); ++i) { s << v[i]; if (i < (int)v.size() - 1) s << "\t"; } return s; }

typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<int> a(2*n);
	for(int i=0; i<2*n; i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	// dry
	int index = 0;
	int rindex = 2*n-1;
	int c_dry = 0;
	while(index<rindex){
		int hum = a[index]+a[rindex]; 
		if(hum < 0){
			c_dry+=1;
			index+=1;
			rindex-=1;
		}
		else{
			rindex-=1;
		}
	}
	// wet
	index = 0;
	rindex = 2*n-1;
	int c_wet = 0;
	while(index<rindex){
		int hum = a[index]+a[rindex]; 
		if(hum > 0){
			c_wet+=1;
			index+=1;
			rindex-=1;
		}
		else{
			index+=1;
		}
	}
	// moist
	index = 0;
	rindex = 2*n-1;
	int c_moist = 0;
	while(index<rindex){
		int hum = a[index]+a[rindex]; 
		if(hum == 0){
			c_moist+=1;
			index+=1;
			rindex-=1;
		}
		else if(hum < 0){
			index+=1;
		}
		else if(hum > 0){
			rindex-=1;
		}
	}
	cout << c_dry << " " << c_wet << " " << c_moist << endl;
	return 0;
}
0