結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
Dadarithm
|
| 提出日時 | 2015-09-14 21:50:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 572 bytes |
| コンパイル時間 | 595 ms |
| コンパイル使用メモリ | 65,132 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 06:30:36 |
| 合計ジャッジ時間 | 1,370 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 10 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int N; vector<int> arr; bool ans = false;
cin >> N;
for (int i = 0; i < N; ++i)
{
int j;
cin >> j;
arr.push_back(j);
}
int sum = 0, nsum = 0;
for (int i = 0; i < arr.size(); ++i)
sum += arr[i];
if (!(sum % 2))
{
sort(arr.begin(), arr.end());
for (int i = 0; i < arr.size(); ++i)
{
nsum += arr[i];
if (sum / 2 == nsum)
ans = true;
else if (sum / 2 < nsum)
break;
}
}
cout << (ans ? "possible" : "impossible") << endl;
return 0;
}
Dadarithm