結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
yamyam122
|
| 提出日時 | 2017-07-20 18:19:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 852 bytes |
| コンパイル時間 | 924 ms |
| コンパイル使用メモリ | 65,236 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-08 17:49:22 |
| 合計ジャッジ時間 | 2,117 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 14 |
ソースコード
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
int ReadNum(){
int n;
std::cin>>n;
std::cin.ignore();
return n;
}
std::vector <int> SetNumVector(const int size){
std::vector <int> v;
for(int i=0; i<size; i++){
v.push_back(ReadNum());
}
return v;
}
int main(){
int count = ReadNum();
std::vector<int>weight =SetNumVector(count);
int weight_sum =std::accumulate(weight.begin(),weight.end(),0);
if((weight_sum%2)!=0){
printf("immpossible\n");
return 0;
}
std::sort(weight.begin(),weight.end(),std::greater<int>());
int t=weight[0];
for(int i=1; i<weight.size(); i++){
if(t+weight[i]<=(weight_sum/2)) t += weight[i];
}
(weight_sum/2)==t ? printf("possible\n") : printf("immpossible\n");
return 0;
}
yamyam122