結果

問題 No.1017 Reiwa Sequence
ユーザー beetbeet
提出日時 2020-03-30 10:25:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 1,041 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 207,788 KB
実行使用メモリ 13,728 KB
最終ジャッジ日時 2023-09-15 23:16:57
合計ジャッジ時間 17,045 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 96 ms
7,772 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 200 ms
12,668 KB
testcase_13 AC 198 ms
12,468 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 93 ms
7,748 KB
testcase_20 AC 93 ms
8,228 KB
testcase_21 AC 93 ms
8,680 KB
testcase_22 AC 93 ms
7,640 KB
testcase_23 AC 93 ms
8,300 KB
testcase_24 AC 92 ms
8,616 KB
testcase_25 AC 91 ms
7,360 KB
testcase_26 AC 91 ms
8,304 KB
testcase_27 AC 93 ms
8,876 KB
testcase_28 AC 92 ms
7,364 KB
testcase_29 AC 92 ms
7,412 KB
testcase_30 AC 91 ms
7,508 KB
testcase_31 AC 93 ms
8,828 KB
testcase_32 AC 93 ms
7,624 KB
testcase_33 AC 92 ms
7,500 KB
testcase_34 AC 94 ms
8,544 KB
testcase_35 AC 91 ms
8,028 KB
testcase_36 AC 94 ms
8,256 KB
testcase_37 AC 93 ms
7,508 KB
testcase_38 AC 93 ms
8,232 KB
testcase_39 AC 93 ms
9,212 KB
testcase_40 AC 207 ms
12,124 KB
testcase_41 AC 205 ms
12,316 KB
testcase_42 AC 207 ms
12,172 KB
testcase_43 AC 206 ms
13,728 KB
testcase_44 AC 225 ms
12,500 KB
testcase_45 AC 208 ms
12,184 KB
testcase_46 AC 209 ms
12,276 KB
testcase_47 AC 204 ms
13,148 KB
testcase_48 AC 221 ms
12,868 KB
testcase_49 AC 224 ms
12,648 KB
testcase_50 AC 221 ms
13,112 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 AC 91 ms
7,936 KB
testcase_53 AC 90 ms
8,032 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,20);

  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