結果

問題 No.190 Dry Wet Moist
ユーザー ttkkggwwttkkggww
提出日時 2022-08-25 13:53:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 885 bytes
コンパイル時間 4,762 ms
コンパイル使用メモリ 264,768 KB
実行使用メモリ 17,240 KB
最終ジャッジ日時 2024-04-20 22:37:01
合計ジャッジ時間 8,367 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
6,816 KB
testcase_01 AC 19 ms
6,940 KB
testcase_02 AC 27 ms
6,940 KB
testcase_03 AC 26 ms
6,944 KB
testcase_04 AC 27 ms
6,940 KB
testcase_05 AC 26 ms
6,944 KB
testcase_06 AC 19 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 28 ms
6,944 KB
testcase_09 AC 27 ms
6,944 KB
testcase_10 AC 27 ms
6,944 KB
testcase_11 AC 26 ms
6,940 KB
testcase_12 AC 112 ms
10,692 KB
testcase_13 AC 135 ms
11,932 KB
testcase_14 AC 111 ms
10,508 KB
testcase_15 AC 144 ms
12,420 KB
testcase_16 AC 170 ms
13,768 KB
testcase_17 AC 49 ms
6,940 KB
testcase_18 AC 92 ms
9,452 KB
testcase_19 AC 161 ms
13,784 KB
testcase_20 AC 124 ms
11,560 KB
testcase_21 AC 44 ms
6,940 KB
testcase_22 AC 213 ms
15,616 KB
testcase_23 AC 240 ms
17,240 KB
testcase_24 WA -
testcase_25 AC 25 ms
6,940 KB
testcase_26 AC 27 ms
6,944 KB
testcase_27 WA -
testcase_28 AC 81 ms
9,052 KB
testcase_29 AC 101 ms
10,260 KB
権限があれば一括ダウンロードができます

ソースコード

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);
			}
		}
		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