提出 #6526623


ソースコード 拡げる

#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;

vector<int64_t> solve(int64_t N, const vector<int64_t> & A) {
    vector<int64_t> t1(N + 1);
    t1[0] = INT64_MIN;
    for (int i1 = 0; i1 < N + 1 - 1; ++ i1) {
        t1[i1 + 1] = ((0 <= i1) ? max<int64_t>(t1[i1], A[i1]) : INT64_MIN);
    }
    auto & g1 = t1;
    vector<int64_t> t2(N + 1);
    t2[0] = INT64_MIN;
    for (int i2 = 0; i2 < N + 1 - 1; ++ i2) {
        t2[i2 + 1] = ((((N - i2) - 1) < N) ? max<int64_t>(t2[i2], A[((N - i2) - 1)]) : INT64_MIN);
    }
    auto & g2 = t2;
    vector<int64_t> t3(N);
    for (int i3 = 0; i3 < N; ++ i3) {
        t3[i3] = max<int64_t>(max<int64_t>(max<int64_t>(INT64_MIN, g1[i3]), g2[(((N - (i3 + 1)) - 1) + 1)]), 0);
    }
    auto & f = t3;
    return f;
}

int main() {
    int64_t n; cin >> n;
    vector<int64_t> a(n);
    for (int64_t i = 0; i < n; ++ i) {
        cin >> a[i];
    }
    auto b = solve(n, a);
    for (int64_t i = 0; i < n; ++ i) {
        cout << b[i] << endl;
    }
    return 0;
}

提出情報

提出日時
問題 C - Exception Handling
ユーザ kimiyuki
言語 C++14 (GCC 5.4.1)
得点 300
コード長 1073 Byte
結果 AC
実行時間 375 ms
メモリ 8064 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 12
セット名 テストケース
Sample a01, a02
All a01, a02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12
ケース名 結果 実行時間 メモリ
a01 AC 1 ms 256 KiB
a02 AC 1 ms 256 KiB
b03 AC 1 ms 256 KiB
b04 AC 1 ms 256 KiB
b05 AC 1 ms 256 KiB
b06 AC 362 ms 8064 KiB
b07 AC 329 ms 8064 KiB
b08 AC 366 ms 8064 KiB
b09 AC 367 ms 8064 KiB
b10 AC 375 ms 8064 KiB
b11 AC 368 ms 8064 KiB
b12 AC 375 ms 8064 KiB