Submission #141514

# Submission time Handle Problem Language Result Execution time Memory
141514 2019-08-08T09:39:31 Z meatrow Safety (NOI18_safety) C++17
13 / 100
62 ms 4344 KB
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int N = 1e3 + 5;

int s[N];
ll dp[N][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, h;
    cin >> n >> h;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int j = 0; j < N; j++) {
        dp[0][j] = abs(s[0] - j);
    }
    for (int i = 1; i < n; i++) {
        int l = 0, r = 0;
        multiset<ll> q;
        for (int j = 0; j < N; j++) {
            while (r < N && r <= j + h) {
                q.insert(dp[i - 1][r]);
                r++;
            }
            while (l < N && l < j - h) {
                q.erase(q.find(dp[i - 1][l]));
                l++;
            }
            dp[i][j] = abs(s[i] - j) + *q.begin();
        }
    }
    ll ans = LLONG_MAX;
    for (int i = 0; i < N; i++) {
        ans = min(ans, dp[n - 1][i]);
    }
    cout << ans;
    return 0; 
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 48 ms 4344 KB Output is correct
14 Correct 31 ms 4216 KB Output is correct
15 Correct 47 ms 4216 KB Output is correct
16 Correct 62 ms 4344 KB Output is correct
17 Correct 56 ms 3960 KB Output is correct
18 Correct 51 ms 3320 KB Output is correct
19 Correct 35 ms 4088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 48 ms 4344 KB Output is correct
14 Correct 31 ms 4216 KB Output is correct
15 Correct 47 ms 4216 KB Output is correct
16 Correct 62 ms 4344 KB Output is correct
17 Correct 56 ms 3960 KB Output is correct
18 Correct 51 ms 3320 KB Output is correct
19 Correct 35 ms 4088 KB Output is correct
20 Incorrect 45 ms 4104 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 48 ms 4344 KB Output is correct
14 Correct 31 ms 4216 KB Output is correct
15 Correct 47 ms 4216 KB Output is correct
16 Correct 62 ms 4344 KB Output is correct
17 Correct 56 ms 3960 KB Output is correct
18 Correct 51 ms 3320 KB Output is correct
19 Correct 35 ms 4088 KB Output is correct
20 Incorrect 45 ms 4104 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Incorrect 3 ms 376 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Incorrect 3 ms 376 KB Output isn't correct
14 Halted 0 ms 0 KB -