結果

問題 No.505 カードの数式2
ユーザー sei0osei0o
提出日時 2017-08-06 10:31:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 664 ms
コンパイル使用メモリ 82,076 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 03:49:23
合計ジャッジ時間 1,528 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 1 ms
6,944 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
6,944 KB
testcase_13 WA -
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
6,940 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
6,940 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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 || a[i] == -1) {
            ans += 1;
        } else {
            ans *= abs(a[i]);
            if (ans == 0) ans += abs(a[i]);
        }
    }

    cout << ans << endl;

    return 0;
}
0