結果

問題 No.190 Dry Wet Moist
ユーザー koyoprokoyopro
提出日時 2020-02-26 00:02:20
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,936 bytes
コンパイル時間 1,205 ms
コンパイル使用メモリ 164,944 KB
実行使用メモリ 14,880 KB
最終ジャッジ日時 2024-04-21 15:46:59
合計ジャッジ時間 10,877 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,056 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1,473 ms
6,784 KB
testcase_13 TLE -
testcase_14 AC 1,342 ms
6,656 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
int N;

int dry(vector<int> A) {
    int ans = 0;
    while(A.size()>1) {
        int sum = A[0] + A[A.size()-1];
        if (sum < 0) {
            ans++;
            A.erase(A.begin());
            A.erase(A.end()-1);
        }
        else {
            A.erase(A.end()-1);
        }
    }
    return ans;
}
int wet(vector<int> A) {
    int ans = 0;
    while(A.size()>1) {
        int sum = A[0] + A[A.size()-1];
        if (sum > 0) {
            ans++;
            A.erase(A.begin());
            A.erase(A.end()-1);
        }
        else {
            A.erase(A.begin());
        }
    }
    return ans;
}
int moist(vector<int> A) {
    int ans = 0;
    while(A.size()>1) {
        int sum = A[0] + A[A.size()-1];
        if (sum==0) {
            ans++;
            A.erase(A.begin());
            A.erase(A.end()-1);
        }
        else if (sum > 0) {
            A.erase(A.end()-1);
        } else {
            A.erase(A.begin());
        }
    }
    return ans;
}

void solve() {
    cin>>N;
    vector<int> A(2*N);
    REP(i,2*N)cin>>A[i];
    sort(ALL(A));
    out("%lld %lld %lld\n", dry(A), wet(A), moist(A));
}
0