結果

問題 No.190 Dry Wet Moist
ユーザー koyoprokoyopro
提出日時 2020-02-26 00:07:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,814 bytes
コンパイル時間 1,740 ms
コンパイル使用メモリ 149,292 KB
実行使用メモリ 5,332 KB
最終ジャッジ日時 2023-08-03 17:36:44
合計ジャッジ時間 3,899 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 21 ms
4,380 KB
testcase_13 AC 25 ms
5,332 KB
testcase_14 AC 20 ms
4,380 KB
testcase_15 AC 28 ms
5,108 KB
testcase_16 AC 35 ms
5,160 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 17 ms
4,376 KB
testcase_19 AC 35 ms
5,116 KB
testcase_20 AC 24 ms
4,376 KB
testcase_21 AC 4 ms
4,384 KB
testcase_22 AC 40 ms
5,156 KB
testcase_23 AC 42 ms
5,204 KB
testcase_24 AC 41 ms
5,040 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 27 ms
4,376 KB
testcase_28 AC 12 ms
4,380 KB
testcase_29 AC 16 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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;
vector<int> A;

int dry() {
    int ans = 0;
    int l=0,r=A.size()-1;
    while(r>l) {
        int sum = A[l] + A[r];
        if (sum < 0) {
            ans++;
            l++;
            r--;
        }
        else {
            r--;
        }
    }
    return ans;
}
int wet() {
    int ans = 0;
    int l=0,r=A.size()-1;
    while(r>l) {
        int sum = A[l] + A[r];
        if (sum > 0) {
            ans++;
            l++;
            r--;
        }
        else {
            l++;
        }
    }
    return ans;
}
int moist() {
    int ans = 0;
    int l=0,r=A.size()-1;
    while(r>l) {
        int sum = A[l] + A[r];
        if (sum==0) {
            ans++;
            l++;
            r--;
        }
        else if (sum > 0) {
            r--;
        } else {
            l++;
        }
    }
    return ans;
}

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