結果

問題 No.4 おもりと天秤
ユーザー cimjnuqy
提出日時 2016-04-18 20:48:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 525 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 64,860 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-04 13:55:27
合計ジャッジ時間 1,170 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n;
  vector<int> vec;
  cin >> n;
  int tmp;
  for(int i=0;i<n;i++){
    cin >> tmp;
    vec.push_back(tmp);
  }
  
  sort(vec.begin(), vec.end());
  
  int left,right;
  left = right = 0;
  
  for(int i=0;i<vec.size();i++){
    if(left < right){
      left += vec[n-i-1];
    }else{
      right += vec[n-i-1];
    }
  }
  
  if(left == right){
    cout << "possible" << endl;
  }else{
    cout << "impossible" << endl;
  }
}
0