結果

問題 No.505 カードの数式2
ユーザー gyosib
提出日時 2017-04-21 23:19:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 554 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 67,876 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 17:43:32
合計ジャッジ時間 1,335 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>

using namespace std;

int main(){
  int n;
  int a0;
  cin >> n;
  n--;
  int minus = 0;
  vector<double> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i] < 0){
      minus++;
    }
  }

  sort(a.begin(), a.end());

  for(int j=0;j<n;j++){
    int now = a0;
    int p = now;
    if(minus % 2 == 0){
      if(p == 1) now++;
      else now *= p;
    }else{
      if(p == 1) now++;
      else if(p>0) now *= p;
      else if(j>0) now *= p;
      else now -= p;
    }
  }
}
0