Submission #308086

# Submission time Handle Problem Language Result Execution time Memory
308086 2020-09-30T03:16:57 Z caoash Lightning Conductor (POI11_pio) C++14
0 / 100
1000 ms 7236 KB
#include <bits/stdc++.h> 
using namespace std;

using ll = long long;

using vi = vector<int>;
using vl = vector<ll>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

const int MX = 500005;
const int MOD = (int) (1e9 + 7);
const ll INF = (ll) 1e18;

int a[MX];
int pre[MX], suf[MX];
int n;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        int j, k, c;
        if (i != 0) {
            for (j = i - 1, k = 1, c = 1; j >= 0; j -= k, k += 2, c++) {
                suf[j] = max(suf[j], a[i] + c);
            }
        }
        if (i != n - 1) {
            for (j = i + 1, k = 1, c = 1; j < n; j += k, k += 2, c++) {
                pre[j] = max(pre[j], a[i] + c);
            }
        }
    }
    for (int i = 1; i < n; i++) {
        pre[i] = max(pre[i - 1], pre[i]);
    }
    for (int i = n - 2; i >= 0; i--) {
        suf[i] = max(suf[i + 1], suf[i]);
    }
    for (int i = 0; i < n; i++) {
        cout << min(0, max(pre[i], suf[i]) - a[i]) << '\n';
    }
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 768 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 1016 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 1272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 1736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 299 ms 3448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 579 ms 5368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 996 ms 7236 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1004 ms 7220 KB Time limit exceeded
2 Halted 0 ms 0 KB -