結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
hitoyozake
|
| 提出日時 | 2018-05-15 20:37:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 971 bytes |
| コンパイル時間 | 688 ms |
| コンパイル使用メモリ | 77,392 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-28 12:10:44 |
| 合計ジャッジ時間 | 1,427 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 6 |
ソースコード
#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;
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;
}
hitoyozake