結果

問題 No.1017 Reiwa Sequence
ユーザー beetbeet
提出日時 2020-03-11 20:47:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,871 ms / 2,000 ms
コード長 1,041 bytes
コンパイル時間 2,469 ms
コンパイル使用メモリ 206,376 KB
実行使用メモリ 70,732 KB
最終ジャッジ日時 2023-09-15 22:51:53
合計ジャッジ時間 38,325 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 96 ms
7,560 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1,838 ms
68,896 KB
testcase_13 AC 1,844 ms
68,820 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 93 ms
8,308 KB
testcase_20 AC 92 ms
7,712 KB
testcase_21 AC 93 ms
7,372 KB
testcase_22 AC 94 ms
8,276 KB
testcase_23 AC 93 ms
7,768 KB
testcase_24 AC 92 ms
7,612 KB
testcase_25 AC 91 ms
7,716 KB
testcase_26 AC 92 ms
7,984 KB
testcase_27 AC 92 ms
9,296 KB
testcase_28 AC 94 ms
7,328 KB
testcase_29 AC 92 ms
7,592 KB
testcase_30 AC 92 ms
8,032 KB
testcase_31 AC 93 ms
7,472 KB
testcase_32 AC 94 ms
7,332 KB
testcase_33 AC 93 ms
8,300 KB
testcase_34 AC 93 ms
8,092 KB
testcase_35 AC 91 ms
8,176 KB
testcase_36 AC 95 ms
8,820 KB
testcase_37 AC 93 ms
8,356 KB
testcase_38 AC 94 ms
7,356 KB
testcase_39 AC 94 ms
8,996 KB
testcase_40 AC 1,842 ms
69,360 KB
testcase_41 AC 1,826 ms
69,456 KB
testcase_42 AC 1,839 ms
70,444 KB
testcase_43 AC 1,841 ms
70,380 KB
testcase_44 AC 1,867 ms
70,576 KB
testcase_45 AC 1,851 ms
69,660 KB
testcase_46 AC 1,843 ms
69,912 KB
testcase_47 AC 1,833 ms
69,708 KB
testcase_48 AC 1,871 ms
70,732 KB
testcase_49 AC 1,798 ms
70,076 KB
testcase_50 AC 1,725 ms
69,936 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 AC 92 ms
7,932 KB
testcase_53 AC 90 ms
7,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;

  vector<int> as(n);
  for(int i=0;i<n;i++) cin>>as[i];

  int m=min(n,23);

  using P = pair<int, int>;
  vector<P> cnt;

  for(int b=1;b<(1<<m);b++){
    int sum=0;
    for(int i=0;i<m;i++)
      if((b>>i)&1) sum+=as[i];
    cnt.emplace_back(sum,b);
  }
  sort(cnt.begin(),cnt.end());

  for(int t=0;t+1<(int)cnt.size();t++){
    if(cnt[t+0].first!=cnt[t+1].first) continue;
    cout<<"Yes"<<endl;

    vector<int> xs(n,0);
    for(int i=0;i<m;i++){
      if((cnt[t+0].second>>i)&1) xs[i]=+1;
      if((cnt[t+1].second>>i)&1) xs[i]=-1;
    }

    for(int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<as[i]*xs[i];
    }
    cout<<endl;
    return 0;
  }

  cout<<"No"<<endl;
  return 0;
}
0