結果
| 問題 |
No.190 Dry Wet Moist
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-19 17:50:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 67 ms / 2,000 ms |
| コード長 | 869 bytes |
| コンパイル時間 | 550 ms |
| コンパイル使用メモリ | 58,616 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 03:56:01 |
| 合計ジャッジ時間 | 1,877 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 |
ソースコード
#include <algorithm>
#include <iostream>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
using namespace std;
int n;
const int N = 200010;
int a[N];
int solve0() {
int s = 0, t = n - 1;
int cnt = 0;
while (s < t) {
if (a[s] + a[t] == 0) {
cnt ++;
s++;
t--;
continue;
}
if (a[s] + a[t] > 0) {
t--;
continue;
}
s++;
}
return cnt;
}
int solve_pos() {
int s = 0, t = n - 1;
int cnt = 0;
while (s < t) {
if (a[s] + a[t] > 0) {
cnt++;
s++;
t--;
continue;
}
s++;
}
return cnt;
}
int main(void){
cin >> n;
n *= 2;
REP(i, 0, n) {
cin >> a[i];
}
sort(a, a + n);
int a0 = solve0();
int a1 = solve_pos();
REP(i, 0, n) {
a[i] = -a[i];
}
reverse(a, a + n);
int a2 = solve_pos();
cout << a2 << " " << a1 << " " << a0 << endl;
}