結果
問題 |
No.1017 Reiwa Sequence
|
ユーザー |
![]() |
提出日時 | 2020-04-04 04:56:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
J_TLE
(最初)
|
実行時間 | - |
コード長 | 1,512 bytes |
コンパイル時間 | 1,752 ms |
コンパイル使用メモリ | 177,792 KB |
実行使用メモリ | 108,032 KB |
最終ジャッジ日時 | 2024-07-03 06:55:45 |
合計ジャッジ時間 | 53,619 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 46 WA * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } const long double EPS = 1e-10; const long long INF = 1e18; const long double PI = acos(-1.0L); //const ll mod = 1000000007; map<ll, vector<ll>> mp; int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; vector<int> A(N), ans(N); for(int i = 0; i < N; i++) cin >> A[i]; for(int i = 0; i < (1 << N); i++) { ll sum = 0; for(int j = 0; j <= min(N, 30LL); j++) { if(i & (1 << j)) sum += A[j]; } if(mp.count(sum)) { for(int j = 0; j <= min(N, 30LL); j++) { if(i & (1 << j)) ans[j] += A[j]; } for(auto tmp : mp[sum]) { ans[tmp] -= A[tmp]; } cout << "Yes" << endl; for(int i = 0; i < N; i++) { if(i != 0) cout << " "; cout << ans[i]; } cout << endl; return 0; } else { for(int j = 0; j <= min(N, 30LL); j++) { if(i & (1 << j)) mp[sum].push_back(j); } } } cout << "No" << endl; return 0; }