結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
hitoyozake
|
| 提出日時 | 2018-05-15 00:56:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 797 bytes |
| コンパイル時間 | 1,087 ms |
| コンパイル使用メモリ | 83,580 KB |
| 実行使用メモリ | 817,632 KB |
| 最終ジャッジ日時 | 2024-06-28 11:57:59 |
| 合計ジャッジ時間 | 4,149 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 MLE * 1 -- * 17 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <stack>
int main()
{
int n = 0;
std::cin >> n;
std::stack<int> buf;
buf.push(0);
for(int i = 0; i < n; ++i)
{
int tmp = 0;
std::cin >> tmp;
std::stack<int> tmpbuf;
while(!buf.empty())
{
auto const a = buf.top();
//std::cout << "a:" << a << std::endl;
buf.pop();
tmpbuf.push(tmp + a);
tmpbuf.push(tmp - a);
}
buf = tmpbuf;
}
bool found = false;
while(!buf.empty())
{
if( buf.top() == 0 )
found = true;
buf.pop();
}
if( found )
std::cout << "possible" << std::endl;
else
std::cout << "impossible" << std::endl;
}
hitoyozake