結果

問題 No.190 Dry Wet Moist
ユーザー ciel
提出日時 2015-04-22 04:25:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 724 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 43,648 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 00:04:39
合計ジャッジ時間 1,702 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other AC * 2 WA * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:35:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   35 |         scanf("%d",&N);
      |         ~~~~~^~~~~~~~~
main.cpp:37:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |         for(int i=0;i<N;i++)scanf("%d",&v[i]);
      |                             ~~~~~^~~~~~~~~~~~

ソースコード

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