結果

問題 No.190 Dry Wet Moist
ユーザー mamekin
提出日時 2015-05-24 14:55:03
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 1,197 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 94,784 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 06:43:19
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
template<class T>
int solve(const vector<int>& a, T comp)
{
int n = a.size();
int i = 0;
int j = n - 1;
int ans = 0;
while(i < j){
int x = comp(a[i], a[j]);
if(x == 0){
++ ans;
++ i;
-- j;
}
else if(x < 0){
++ i;
}
else{
-- j;
}
}
return ans;
}
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());
int dry = solve(a, [](int x, int y){ return max(0, y + x + 1); });
int wet = solve(a, [](int x, int y){ return min(0, y + x - 1); });
int moist = solve(a, [](int x, int y){ return y + x; });
cout << dry << ' ' << wet << ' ' << moist << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0