結果

問題 No.190 Dry Wet Moist
ユーザー fiord
提出日時 2015-11-19 21:15:15
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 1,495 ms
コンパイル使用メモリ 162,448 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-13 17:03:36
合計ジャッジ時間 4,381 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	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 s=0,t=a.size()-1;
	int dry=0,moist=0,wet=0;
	while(s<t){
		if(a[s]+a[t]<0){
			dry++;	s++;	t--;
		}
		else 	t--;
	}
	s=0,t=a.size()-1;
	while(s<t){
		if(a[s]+a[t]==0){
			moist++;	s++;	t--;
		}
		else if(a[s]+a[t]>0){//a[t]が大きすぎる
			t--;
		}
		else 	s++;
	}
	s=0,t=a.size()-1;
	while(s<t){
		if(a[s]+a[t]>0){
			wet++;	s++;	t--;
		}
		else 	s++;
	}
	cout<<dry<<" "<<wet<<" "<<moist<<endl;
	return 0;
}
0