結果

問題 No.190 Dry Wet Moist
ユーザー ttkkggwwttkkggww
提出日時 2022-08-25 13:55:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 957 bytes
コンパイル時間 4,662 ms
コンパイル使用メモリ 263,032 KB
実行使用メモリ 17,264 KB
最終ジャッジ日時 2024-04-20 22:40:31
合計ジャッジ時間 9,094 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
5,980 KB
testcase_01 AC 27 ms
5,984 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 314 ms
17,264 KB
testcase_24 WA -
testcase_25 AC 34 ms
6,000 KB
testcase_26 AC 33 ms
5,980 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(){
	for(int _ = 0;_ < 2; _++){
		for(int i = 0;i<n*2;i++)a[i] *= -1;
		fenwick_tree<ll> BIT(300000);
		for(int i = 0;i<n*2;i++){
			BIT.add(a[i]+150000,1);
		}
		ll ans = 0;
		for(int i = 1;i<300000-1;i++){
			if(BIT.sum(-i+300000+1,300000)>0){
				ll add = min(BIT.sum(i,i+1),BIT.sum(max(-i+300000+1,i+1),300000));
				add = max(0ll,add);
				ans += add;
				BIT.add(i,-add);
				BIT.add(300000-1,-add);
			}
		}
		for(int i = 150000+1;i<300000-1;i++){
			ans += BIT.sum(i,i+1)/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