結果
問題 |
No.1017 Reiwa Sequence
|
ユーザー |
![]() |
提出日時 | 2020-04-03 22:53:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 862 bytes |
コンパイル時間 | 2,254 ms |
コンパイル使用メモリ | 176,824 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-03 05:23:33 |
合計ジャッジ時間 | 29,044 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 14 WA * 36 |
ソースコード
#include<bits/stdc++.h> int main(){ int N;std::cin>>N; std::vector<std::pair<long long,int>> A(N); long long sum=0; for(int i=0;i<N;++i){ std::cin>>A[i].first; A[i].second=i; sum+=A[i].first; } std::sort(A.rbegin(),A.rend()); for(int i=0;i<N-1;++i){ if(sum-2*A[i].first>=A.back().first){ sum -= 2*A[i].first; A[i].first = -A[i].first; } else if(sum-A[i].first>=A.back().first){ sum -= A[i].first; A[i].first=0; } } for(int i=0;i<=2;++i) if(sum==i*A[i].first){ using P = std::pair<long long,int>; std::sort(A.begin(),A.end(),[](P a,P b){return a.second<b.second;}); std::cout<<"Yes\n"; for(auto s:A) std::cout<<s.first<<" \n"[s.second==N-1]; return 0; } std::cout<<"No\n"; }