# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
963704 | 2024-04-15T13:58:13 Z | guechotjrhh | Safety (NOI18_safety) | C++14 | 2000 ms | 860 KB |
#include<stdio.h> #include<vector> #pragma warning (disable:4996) using namespace std; #define ll long long ll ab(ll n) { return n > 0 ? n : -n; } int sz = 5001; long long func(int n, int h, vector<int> s) { vector<ll> dp(sz,0); int mi = 0; for (int i = 0; i < n; i++) { vector<ll> ndp(sz); for (int j = 0; j < sz; j++) { ndp[j] = ab(j - s[i]); int d = max(0, j - h), u = min(sz - 1, j + h); if (d <= mi && u >= mi) ndp[j] += dp[mi]; if (d > mi) ndp[j] += dp[d]; if (u < mi) ndp[j] += dp[u]; //ll mn = 1e18; //for (int k = max(0, j - h); k <= min(sz-1, j + h); k++) mn = min(mn, dp[k]); //ndp[j] += mn; } //for (int j : dp) printf("%d ", j); printf("\n"); dp = ndp; mi = 0; for (int i = 0; i < sz; i++) if (dp[i] < dp[mi]) mi = i; } ll mn = 1e18; for (int i = 0; i < sz; i++) mn = min(mn, dp[i]); return mn; } int main() { int N, H; scanf("%d%d", &N, &H); vector<int> S(N); for (int i = 0; i < N; i++) scanf("%d", &S[i]); long long ans = func(N, H, move(S)); printf("%d\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 600 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2052 ms | 860 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 600 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 13 ms | 348 KB | Output is correct |
14 | Correct | 11 ms | 348 KB | Output is correct |
15 | Correct | 11 ms | 348 KB | Output is correct |
16 | Correct | 12 ms | 348 KB | Output is correct |
17 | Correct | 11 ms | 344 KB | Output is correct |
18 | Correct | 9 ms | 492 KB | Output is correct |
19 | Correct | 12 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 600 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 13 ms | 348 KB | Output is correct |
14 | Correct | 11 ms | 348 KB | Output is correct |
15 | Correct | 11 ms | 348 KB | Output is correct |
16 | Correct | 12 ms | 348 KB | Output is correct |
17 | Correct | 11 ms | 344 KB | Output is correct |
18 | Correct | 9 ms | 492 KB | Output is correct |
19 | Correct | 12 ms | 344 KB | Output is correct |
20 | Correct | 11 ms | 348 KB | Output is correct |
21 | Correct | 12 ms | 500 KB | Output is correct |
22 | Correct | 11 ms | 500 KB | Output is correct |
23 | Correct | 9 ms | 544 KB | Output is correct |
24 | Correct | 11 ms | 348 KB | Output is correct |
25 | Correct | 9 ms | 348 KB | Output is correct |
26 | Correct | 12 ms | 508 KB | Output is correct |
27 | Correct | 11 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 600 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 13 ms | 348 KB | Output is correct |
14 | Correct | 11 ms | 348 KB | Output is correct |
15 | Correct | 11 ms | 348 KB | Output is correct |
16 | Correct | 12 ms | 348 KB | Output is correct |
17 | Correct | 11 ms | 344 KB | Output is correct |
18 | Correct | 9 ms | 492 KB | Output is correct |
19 | Correct | 12 ms | 344 KB | Output is correct |
20 | Correct | 11 ms | 348 KB | Output is correct |
21 | Correct | 12 ms | 500 KB | Output is correct |
22 | Correct | 11 ms | 500 KB | Output is correct |
23 | Correct | 9 ms | 544 KB | Output is correct |
24 | Correct | 11 ms | 348 KB | Output is correct |
25 | Correct | 9 ms | 348 KB | Output is correct |
26 | Correct | 12 ms | 508 KB | Output is correct |
27 | Correct | 11 ms | 348 KB | Output is correct |
28 | Correct | 120 ms | 512 KB | Output is correct |
29 | Correct | 108 ms | 508 KB | Output is correct |
30 | Correct | 116 ms | 512 KB | Output is correct |
31 | Correct | 91 ms | 504 KB | Output is correct |
32 | Correct | 99 ms | 344 KB | Output is correct |
33 | Correct | 119 ms | 512 KB | Output is correct |
34 | Correct | 108 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 600 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Incorrect | 1 ms | 348 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 600 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Incorrect | 1 ms | 348 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |