結果

問題 No.190 Dry Wet Moist
コンテスト
ユーザー kzyKT
提出日時 2015-04-22 01:22:57
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,279 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,018 ms
コンパイル使用メモリ 180,188 KB
実行使用メモリ 16,000 KB
最終ジャッジ日時 2026-03-26 06:00:08
合計ジャッジ時間 2,681 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:1:
In function 'const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]',
    inlined from 'int main()' at main.cpp:44:14:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:239:15: warning: iteration 1000000 invokes undefined behavior [-Waggressive-loop-optimizations]
  239 |       if (__b < __a)
      |           ~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:5:40: note: within this loop
    5 | #define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
      |                                        ^
main.cpp:6:18: note: in expansion of macro 'REP'
    6 | #define rep(i,n) REP(i,0,n)
      |                  ^~~
main.cpp:42:3: note: in expansion of macro 'rep'
   42 |   rep(i,t+1) {
      |   ^~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int c[3000001];
int main() {
  int n;
  cin >> n;
  int a[n*2],t=1000000;
  memset(c,0,sizeof(c));
  rep(i,n*2) {
    cin >> a[i];
    c[a[i]+t]++;
  }
  sort(a,a+n);
  int d=0,w=0,m=0;
  REP(i,1,t+1) if(c[t+i] && c[t-i]) m+=min(c[t+i],c[t-i]);
  m+=c[t]/2;
  int sum=0;
  REP(i,1,t+1) {
    sum+=c[t-i+1];
    int x=min(sum,c[t+i]);
    sum-=x;
    w+=x;
  }
  sum=0;
  rep(i,t+1) {
    sum+=c[t+i];
    int x=min(sum,c[t-i-1]);
    sum-=x;
    d+=x;
  }
  int c1=0,c2=0;
  rep(i,t*2+1) {
    if(i<t) c1+=c[i];
    else if(i>t) c2+=c[i];
  }
  c1-=d;
  c2-=w;
  cout << d+c1/2 << " " << w+c2/2 << " " << m << endl;
  return 0;
}
0