結果
問題 | No.190 Dry Wet Moist |
ユーザー |
![]() |
提出日時 | 2016-07-18 02:43:58 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 38 ms / 2,000 ms |
コード長 | 1,214 bytes |
コンパイル時間 | 464 ms |
コンパイル使用メモリ | 59,352 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 15:30:18 |
合計ジャッジ時間 | 3,235 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
#include <iostream>#include <algorithm>using namespace std;const int kMAX_N = 100010;const int kMAX_ABS_A = 100010;int A[kMAX_N * 2];int N;int pos_count[kMAX_ABS_A], neg_count[kMAX_ABS_A];int main() {cin.tie(0);ios::sync_with_stdio(false);cin >> N;for (int i = 0; i < 2 * N; i++) {cin >> A[i];if (A[i] >= 0) pos_count[A[i]]++;else neg_count[-A[i]]++;}sort(A, A + 2 * N);int left = 0, right = 2 * N - 1, wet = 0, dry = 0, moist = 0;while (left < right) {while (left < right && A[left] + A[right] <= 0) {left++;}if (left < right) {wet++;}left++;right--;}left = 0, right = 2 * N - 1;while (left < right) {while (left < right && A[left] + A[right] >= 0) {right--;}if (left < right) {dry++;}left++;right--;}for (int i = 0; i < kMAX_ABS_A; i++) {if (i == 0) moist += pos_count[i] / 2;else {moist += min(pos_count[i], neg_count[i]);}}cout << dry << " " << wet << " " << moist << endl;return 0;}