結果
問題 | No.190 Dry Wet Moist |
ユーザー |
|
提出日時 | 2016-11-01 17:18:16 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 1,458 bytes |
コンパイル時間 | 550 ms |
コンパイル使用メモリ | 64,992 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-25 00:57:22 |
合計ジャッジ時間 | 3,338 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
#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.htmltemplate<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());// dryint 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;}}// wetindex = 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;}}// moistindex = 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;}