結果

問題 No.190 Dry Wet Moist
ユーザー furafura
提出日時 2020-07-04 21:23:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 2,290 ms
コンパイル使用メモリ 216,992 KB
実行使用メモリ 14,332 KB
最終ジャッジ日時 2023-10-19 15:51:30
合計ジャッジ時間 5,214 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 120 ms
9,052 KB
testcase_23 AC 193 ms
14,332 KB
testcase_24 AC 125 ms
9,052 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int solve1(vector<int> a){
	int n=a.size();
	sort(a.rbegin(),a.rend());

	int res=0,idx=n-1;
	rep(i,n){
		if(idx>i && a[i]+a[idx]<=0){
			idx--;
		}
		if(idx>i && a[i]+a[idx]>0){
			res++;
			idx--;
		}
	}
	return res;
}

int solve2(vector<int> a){
	int n=a.size();
	map<int,int> f;
	rep(i,n) ++f[a[i]];

	int res=0;
	for(auto it=f.begin();it!=f.end();++it){
		auto [x,c]=*it;
		if(x>0) break;
		if(x==0){
			res+=c/2;
		}
		else if(f.count(-x)>0) {
			res+=min(c,f[-x]);
		}
	}
	return res;
}

int main(){
	int n; scanf("%d",&n); n*=2;
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	rep(i,n) a[i]*=-1;
	printf("%d ",solve1(a));
	rep(i,n) a[i]*=-1;
	printf("%d %d\n",solve1(a),solve2(a));

	return 0;
}
0