結果

問題 No.190 Dry Wet Moist
ユーザー ttkkggwwttkkggww
提出日時 2022-08-25 14:04:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,010 bytes
コンパイル時間 4,272 ms
コンパイル使用メモリ 268,492 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-04-20 22:45:50
合計ジャッジ時間 11,859 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
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 WA -
testcase_23 AC 688 ms
17,408 KB
testcase_24 WA -
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int n;
vector<ll> a;

void solve(){
	sort(a.begin(),a.end());
	for(auto &i:a)cerr<<i<<' ';cerr<<endl;
	for(int _ = 0;_ < 2; _++){
		for(int i = 0;i<n*2;i++)a[i] *= -1;
		set<int> ng,pg,zero;
		for(int i = 0;i<n*2;i++){
			if(a[i]<0)ng.insert(a[i]);
			else if(a[i]>0)pg.insert(a[i]);
			else zero.insert(a[i]);
		}
		int ans =0;
		for(auto &i:ng){
			auto it = pg.upper_bound(-i);
			if(pg.end()!=it){
				pg.erase(it);
				ans++;
			}
		}
		int zerocnt = zero.size();
		int pgcnt = pg.size();
		ans += min(zerocnt,pgcnt);
		pgcnt -= min(zerocnt,pgcnt);
		ans += pgcnt/2;
		cout<<ans<<' ';
	}
	map<ll,ll> mp;
	for(int i = 0;i<n*2;i++){
		mp[a[i]]++;
		mp[-a[i]]+=0;
	}
	ll ans =0;
	for(auto &i:mp){
		ans += min(i.second,mp[-i.first]);
	}
	cout<<ans/2<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n;
	a = vector<ll>(n*2);
	for(auto &i:a)cin >> i;
	solve();
}
0