結果

問題 No.190 Dry Wet Moist
ユーザー snuke
提出日時 2015-04-22 00:09:04
言語 C++11
(gcc 4.8.5)
結果
AC  
実行時間 41 ms
コード長 1,894 Byte
コンパイル時間 657 ms
使用メモリ 2,304 KB
最終ジャッジ日時 2019-03-17 00:30:23

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
00_sample_01.in AC 4 ms
1,528 KB
00_sample_02.in AC 4 ms
1,528 KB
10_small_01.in AC 4 ms
1,524 KB
10_small_02.in AC 4 ms
1,524 KB
10_small_03.in AC 4 ms
1,528 KB
10_small_04.in AC 3 ms
1,528 KB
10_small_05.in AC 2 ms
1,524 KB
20_small_01.in AC 4 ms
1,540 KB
20_small_02.in AC 3 ms
1,528 KB
20_small_03.in AC 3 ms
1,524 KB
20_small_04.in AC 3 ms
1,532 KB
20_small_05.in AC 3 ms
1,524 KB
30_large_01.in AC 22 ms
1,964 KB
30_large_02.in AC 27 ms
2,076 KB
30_large_03.in AC 22 ms
1,952 KB
30_large_04.in AC 29 ms
2,120 KB
30_large_05.in AC 37 ms
2,288 KB
30_large_06.in AC 8 ms
1,624 KB
30_large_07.in AC 19 ms
1,876 KB
30_large_08.in AC 35 ms
2,280 KB
30_large_09.in AC 25 ms
2,040 KB
30_large_10.in AC 6 ms
1,596 KB
40_corner_01.in AC 40 ms
2,304 KB
40_corner_02.in AC 41 ms
2,304 KB
40_corner_03.in AC 40 ms
2,304 KB
40_corner_04.in AC 3 ms
1,528 KB
40_corner_05.in AC 4 ms
1,524 KB
system_test1.txt AC 28 ms
2,024 KB
system_test2.txt AC 14 ms
1,748 KB
system_test3.txt AC 18 ms
1,812 KB
テストケース一括ダウンロード

ソースコード

diff #
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cctype>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
#define drep(i,n) for(int i = n-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}

const int MX = 100005, INF = 1000010000;
const ll LINF = 1000000000000000000ll;
const double eps = 1e-10;
const int di[] = {-1,0,1,0}, dj[] = {0,-1,0,1}; //^<v>

int n, m;
int a[MX*2];

int sol() {
  int ans = 0;
  for (int i = 0, j = m-1; i < j;) {
    while (i < j && a[i]+a[j] <= 0) ++i;
    if (i < j) {
      ans++;
      ++i;
      --j;
    }
  }
  return ans;
}

int sol2() {
  int ans = 0;
  for (int i = 0, j = m-1; i < j;) {
    if (a[i]+a[j] > 0) {
      --j;
    } else if(a[i]+a[j] < 0) {
      ++i;
    } else {
      ans++;
      --j;
      ++i;
    }
  }
  return ans;
}

int main(){
  scanf("%d",&n);
  m = n*2;
  rep(i,m) scanf("%d",&a[i]);
  sort(a,a+m);
  int ans1 = sol();
  rep(i,m) a[i] = -a[i];
  sort(a,a+m);
  int ans2 = sol();
  int ans3 = sol2();
  priv({ans2,ans1,ans3});
  return 0;
}




0