結果
| 問題 |
No.190 Dry Wet Moist
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-08-12 15:59:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 2,000 ms |
| コード長 | 1,126 bytes |
| コンパイル時間 | 1,377 ms |
| コンパイル使用メモリ | 161,800 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-18 06:57:55 |
| 合計ジャッジ時間 | 3,843 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const int offset = 100000;
int N, a[200000];
int b[offset * 2 + 1];
int main() {
cin >> N;
rep (i, 2 * N) {
cin >> a[i];
b[a[i] + offset]++;
}
sort(a, a + 2 * N);
int pos = 0, neg = 0, zero = 0;
// calc pos
int r = N * 2 - 1;
rep (i, N * 2) {
if (i >= r) break;
if (r > 0 && a[i] + a[r] > 0) {
pos++;
r--;
}
}
// calc neg
int l = 0;
repr (i, N * 2) {
if (l >= i) break;
if (l < N * 2 - 1 && a[l] + a[i] < 0) {
neg++;
l++;
}
}
ll z = 0;
rep2 (i, 1, offset + 1) {
z += min(b[offset + i], b[offset - i]);
}
z += b[offset] / 2;
z = min<ll>(z, N);
cout << neg << " " << pos << " " << z << endl;
}