結果
問題 | No.190 Dry Wet Moist |
ユーザー |
|
提出日時 | 2015-04-22 03:44:32 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 842 bytes |
コンパイル時間 | 362 ms |
コンパイル使用メモリ | 44,160 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 23:55:28 |
合計ジャッジ時間 | 1,746 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:46:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 46 | scanf("%d",&N),N*=2; | ~~~~~^~~~~~~~~ main.cpp:48:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 48 | for(int i=0;i<N;i++)scanf("%d",&v[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#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;){if(v[lo]>=0)break;for(;lo<hi;hi--)if(v[lo]+v[hi]<0)break;if(lo==hi)break;R++;lo++;hi--;}return R;}int wet(vector<int> &v){int R=0,lo=0,hi=v.size()-1;for(;lo<hi;){if(v[hi]<=0)break;for(;lo<hi;lo++)if(v[lo]+v[hi]>0)break;if(lo==hi)break;R++;lo++;hi--;}return R;}int moist(vector<int> &v){int R=0,lo=0,hi=v.size()-1;for(;lo<hi;){if(v[lo]>0)break;for(;lo<hi;hi--)if(v[lo]+v[hi]<=0)break;if(lo==hi)break;if(v[lo]+v[hi]==0)R++,hi--;lo++;}return R;}int main(){int N;scanf("%d",&N),N*=2;vector<int>v(N);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));}