結果

問題 No.505 カードの数式2
ユーザー sei0o
提出日時 2017-08-06 10:30:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 688 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 81,576 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-11 22:42:49
合計ジャッジ時間 1,534 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 5 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

// 解説、見ました

#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;
using ll = long long;
const ll INF = 1e9;

int main() {
    int N;
    cin >> N;
    int a[N], cnt = 0, cnt1 = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] < -1) cnt++;
        if (a[i] == -1) {
            cnt++; cnt1++;
        }
    }
    int ans = a[0];

    for (int i = 1; i < N; i++) {
        if (a[i] == 1 || a[i] == 0) {
            ans += 1;
        } else {
            ans *= abs(a[i]);
            if (ans == 0) ans += abs(a[i]);
        }
    }

    cout << ans << endl;

    return 0;
}
0