結果
問題 | No.1017 Reiwa Sequence |
ユーザー |
![]() |
提出日時 | 2020-04-04 05:00:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
J_TLE
(最初)
|
実行時間 | - |
コード長 | 1,638 bytes |
コンパイル時間 | 2,219 ms |
コンパイル使用メモリ | 184,952 KB |
実行使用メモリ | 107,392 KB |
最終ジャッジ日時 | 2024-07-03 06:57:56 |
合計ジャッジ時間 | 45,937 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 49 WA * 1 |
ソースコード
#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); vector<l_l> v(N); for(int i = 0; i < N; i++) { cin >> A[i]; v[i] = {A[i], i}; } sort(v.begin(), v.end()); 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 += v[j].first; } if(mp.count(sum)) { for(int j = 0; j <= min(N, 30LL); j++) { if(i & (1 << j)) ans[v[j].second] += v[j].first; } 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(v[j].second); } } } cout << "No" << endl; return 0; }