結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2018-05-15 20:41:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 992 bytes |
コンパイル時間 | 813 ms |
コンパイル使用メモリ | 78,072 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-28 12:10:52 |
合計ジャッジ時間 | 1,565 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 4 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <stack> #include <algorithm> #include <numeric> int main() { int n = 0; std::cin >> n; bool found = false; std::vector< int > v; for( int i = 0; i < n; ++i ) { int tmp; std::cin >> tmp; v.push_back(tmp); } std::sort(v.begin(), v.end()); int sum = std::accumulate(v.begin(), v.end(), 0); int h = sum/2; if(sum % 2 == 0) for( auto it = v.rbegin(); it != v.rend(); ++it ) { //std::cout << "it: " << *it << std::endl; if(sum - *it >= h ) { sum -= *it; } else { sum -= *it; h -= *it; } //std::cout << "sum: " << sum << ", half:" << h << std::endl; } if( sum == 0 && h == 0 ) found = true; if( found ) std::cout << "possible" << std::endl; else std::cout << "impossible" << std::endl; }