結果

問題 No.190 Dry Wet Moist
ユーザー koprickykopricky
提出日時 2017-07-29 05:19:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,796 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 171,692 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2024-04-19 04:39:53
合計ジャッジ時間 7,613 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
12,672 KB
testcase_01 AC 54 ms
12,672 KB
testcase_02 AC 53 ms
12,800 KB
testcase_03 AC 55 ms
12,672 KB
testcase_04 AC 54 ms
12,672 KB
testcase_05 AC 54 ms
12,672 KB
testcase_06 AC 55 ms
12,800 KB
testcase_07 WA -
testcase_08 AC 55 ms
12,928 KB
testcase_09 AC 55 ms
12,800 KB
testcase_10 WA -
testcase_11 AC 54 ms
12,800 KB
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 415 ms
22,656 KB
testcase_23 AC 475 ms
22,784 KB
testcase_24 AC 444 ms
22,656 KB
testcase_25 WA -
testcase_26 AC 54 ms
12,672 KB
testcase_27 WA -
testcase_28 AC 127 ms
15,488 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

map<int,int> mp;

int main()
{
    int n;
    cin >> n;
    vector<int> vec(2*n);
    rep(i,2*n){
        cin >> vec[i];
        mp[vec[i]]++;
    }
    multiset<int> st;
    rep(i,2*n){
        st.insert(vec[i]);
    }
    int ans1 = 0;
    while(st.size() > 0){
        int a = *st.begin();
        if(a >= 0){
            break;
        }
        auto it = st.lower_bound(-a);
        it--;
        if(it != st.begin()){
            st.erase(it);
            st.erase(st.begin());
            ans1++;
        }else{
            break;
        }
    }
    int ans2 = 0;
    rep(i,100001){
        ans2 += min(mp[i],mp[-i]);
    }
    st.clear();
    rep(i,2*n){
        st.insert(vec[i]);
    }
    int ans3 = 0;
    while(st.size() > 0){
        auto it = st.end();
        it--;
        int a = *it;
        if(a <= 0){
            break;
        }
        it = st.upper_bound(-a);
        it++;
        if(it != st.end()){
            it--;
            st.erase(it);
            it = st.end();
            it--;
            st.erase(it);
            ans3++;
        }else{
            break;
        }
    }
    cout << ans1 << " " << ans3 << " " << ans2 << "\n";
    return 0;
}
0