結果

問題 No.190 Dry Wet Moist
ユーザー sugim48sugim48
提出日時 2015-04-22 00:17:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,340 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 96,188 KB
実行使用メモリ 5,528 KB
最終ジャッジ日時 2023-09-18 03:28:36
合計ジャッジ時間 3,295 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 3 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,384 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 41 ms
4,752 KB
testcase_13 AC 53 ms
5,072 KB
testcase_14 AC 41 ms
4,588 KB
testcase_15 AC 57 ms
5,036 KB
testcase_16 AC 72 ms
5,428 KB
testcase_17 AC 11 ms
4,380 KB
testcase_18 AC 34 ms
4,564 KB
testcase_19 AC 72 ms
5,528 KB
testcase_20 AC 50 ms
4,876 KB
testcase_21 AC 8 ms
4,384 KB
testcase_22 AC 86 ms
5,416 KB
testcase_23 AC 92 ms
5,420 KB
testcase_24 AC 92 ms
5,428 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 3 ms
4,384 KB
testcase_27 AC 58 ms
4,880 KB
testcase_28 AC 26 ms
4,380 KB
testcase_29 AC 33 ms
4,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int f(int N, vector<int> A) {
	sort(A.begin(), A.end());
	int j = N - 1, cnt = 0;
	for (int i = 0; i < N && i < j; i++)
		if (A[i] + A[j] > 0) {
			cnt++;
			j--;
		}
	return cnt;
}

int main() {
	int N; cin >> N;
	N *= 2;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	int k = 0;
	vector<int> a(100001), b(100001);
	for (int i = 0; i < N; i++) {
		if (A[i] == 0) k++;
		if (A[i] > 0) a[A[i]]++;
		if (A[i] < 0) b[-A[i]]++;
	}
	int moist = k / 2;
	for (int j = 1; j <= 100000; j++)
		moist += min(a[j], b[j]);
	int wet = f(N, A);
	for (int i = 0; i < N; i++)
		A[i] *= -1;
	int dry = f(N, A);
	cout << dry << ' ' << wet << ' ' << moist << endl;
}
0